Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[$250] Contact method - Two error messages appear the same time #55490

Open
1 of 8 tasks
lanitochka17 opened this issue Jan 20, 2025 · 15 comments
Open
1 of 8 tasks

[$250] Contact method - Two error messages appear the same time #55490

lanitochka17 opened this issue Jan 20, 2025 · 15 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Jan 20, 2025

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.86-3
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team

Action Performed:

  1. Go to URL https://staging.new.expensify.com/
  2. Login with any account
  3. Go to Settings -> Profile -> Contact methods
  4. Enter a new contact method -> Don't validate
  5. Several times click Didn't receive a magic code? until you get an error message
  6. Then enter incorrect magic code -> Verify

Expected Result:

The previous error must disappear when the next one appears

Actual Result:

Two error messages appear at the same time

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Bug6704213_1736242730055.bandicam_2025-01-07_15-04-37-042.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021882050166066042062
  • Upwork Job ID: 1882050166066042062
  • Last Price Increase: 2025-01-22
  • Automatic offers:
    • Krishna2323 | Contributor | 105907621
Issue OwnerCurrent Issue Owner: @parasharrajat
@lanitochka17 lanitochka17 added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Jan 20, 2025
Copy link

melvin-bot bot commented Jan 20, 2025

Triggered auto assignment to @zanyrenney (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

Copy link
Contributor

⚠️ @Krishna2323 Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

@Krishna2323
Copy link
Contributor

Krishna2323 commented Jan 20, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-01-21 05:01:01 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Contact method - Two error messages appear the same time

What is the root cause of that problem?

What changes do you think we should make in order to solve the problem?

    const validateAndSubmitForm = useCallback(() => {
        User.clearValidateCodeActionError('actionVerified');
        if (!validateCode.trim()) {
            setFormError({validateCode: 'validateCodeForm.error.pleaseFillMagicCode'});
            return;
        }

        if (!ValidationUtils.isValidValidateCode(validateCode)) {
            setFormError({validateCode: 'validateCodeForm.error.incorrectMagicCode'});
            return;
        }

        setFormError({});
        handleSubmitForm(validateCode);
    }, [validateCode, handleSubmitForm]);

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA

What alternative solutions did you explore? (Optional)

@Shahidullah-Muffakir
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Two error messages appears at the same time

What is the root cause of that problem?

  1. When user tries to send a new magic code multiple times with ResendValidateCode endpoint, we get the error Failed to send a new magic code. because of the limit, and then we are storing this error in the ONYXKEYS.VALIDATE_ACTION_CODE key , under actionVerified property:
    errorFields: {
    actionVerified: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('contacts.genericFailureMessages.requestContactMethodValidateCode'),
    },
  2. When user types a incorrect magic code and click verify , the AddNewContactMethod endpoint returns a new error message for the wrong magic code
  3. The issue occurs because at the point 2, if user gets a new error we are not clearing the the previous error
    function addNewContactMethod(contactMethod: string, validateCode = '') {

What changes do you think we should make in order to solve the problem?

To remove the previous error, we can clear the VALIDATE_ACTION_CODE error message whenever user clicks the Verify Btn and addNewContactMethod returns a new error.
here:

function addNewContactMethod(contactMethod: string, validateCode = '') {

in the failureData we can add this:

        {
            onyxMethod: Onyx.METHOD.MERGE,
            key: ONYXKEYS.VALIDATE_ACTION_CODE,
            value: {
                errorFields: {
                    actionVerified: null,
                },
            },
        },

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

NA

What alternative solutions did you explore? (Optional)

NA

Screen.Recording.2025-01-21.at.9.15.23.AM.mov

@Krishna2323
Copy link
Contributor

PROPOSAL UPDATED

  • Added an optional change

@zanyrenney
Copy link
Contributor

Image

@zanyrenney zanyrenney added the External Added to denote the issue can be worked on by a contributor label Jan 22, 2025
Copy link

melvin-bot bot commented Jan 22, 2025

Job added to Upwork: https://www.upwork.com/jobs/~021882050166066042062

@melvin-bot melvin-bot bot changed the title Contact method - Two error messages appear the same time [$250] Contact method - Two error messages appear the same time Jan 22, 2025
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 22, 2025
Copy link

melvin-bot bot commented Jan 22, 2025

Triggered auto assignment to Contributor-plus team member for initial proposal review - @parasharrajat (External)

@zanyrenney
Copy link
Contributor

hey @parasharrajat - please review the proposals above and let me know which looks good!

@FitseTLT
Copy link
Contributor

FitseTLT commented Jan 23, 2025

🚨 Edited by proposal-police: This proposal was edited at 2025-01-23 21:25:51 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Contact method - Two error messages appear the same time

What is the root cause of that problem?

We already have a pattern to clear errors on text input here

if (!isEmptyObject(validateError)) {
clearError();
clearValidateCodeActionError('actionVerified');
}
},

but we are only clearing both errors when the validateError is not empty so it will not clear the validateCodeActionError when validateError doesn't exist

What changes do you think we should make in order to solve the problem?

We need to clear validateError only if it exists and similarly for validateCodeActionError so we shouldn't have a common condition for clearing of the two different errors as they are independent errors. So we should update

if (!isEmptyObject(validateError)) {
clearError();
clearValidateCodeActionError('actionVerified');
}
},

  if (!isEmptyObject(validateError)) {
                clearError();
            }
            if (!isEmptyObject(getLatestErrorField(validateCodeAction, 'actionVerified'))) {
                clearValidateCodeActionError('actionVerified');
            }

Additionally we can also consider clearing both errors on validateAndSubmitForm here.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

N/A

What alternative solutions did you explore? (Optional)

@parasharrajat
Copy link
Member

I will start looking into the proposals today.

@parasharrajat
Copy link
Member

Following the same pattern on clearing the error text input makes sense. I think that there was a case on why we are removing both errors together on text input change. Thus @Krishna2323's proposal looks good to me and they proposed first.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Jan 29, 2025

Triggered auto assignment to @carlosmiceli, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Jan 29, 2025
Copy link

melvin-bot bot commented Jan 29, 2025

📣 @Krishna2323 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@Krishna2323
Copy link
Contributor

@parasharrajat PR is ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Reviewing Has a PR in review Weekly KSv2
Projects
None yet
Development

No branches or pull requests

7 participants