Skip to content

[PAYMENT DUE MAY 14] [$250] Android - Enter magic code error is displayed simultaneously with incorrect code error #39873

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 1.4.61-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4483896
Issue reported by: Applause - Internal Team

Action Performed:

  1. Open the app and enter a new account email
  2. Repeat the previous step with the same email to receive two validation links
  3. Tap on ''Sign In''
  4. Navigate to the account email inbox and open the first email of the two

Expected Result:

The error message "Please enter your magic code" should be dismissed, and only the error about the incorrect magic code should be displayed, as the user just used a magic code link that is equivalent to entering a magic cod

Actual Result:

The user encounters the first error message ("Please enter your magic code") despite having just used the expired magic code link (equivalent to a magic code). Both errors regarding incorrect and entering the magic code are displayed simultaneously

Workaround:

Unknown

Platforms:

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

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6442626_1712599447662.Android_-_Expired_-_Incorrect.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~01d7b54fd3dba64e10
  • Upwork Job ID: 1778153488874250240
  • Last Price Increase: 2024-04-24
  • Automatic offers:
    • hoangzinh | Reviewer | 0
    • tienifr | Contributor | 0
Issue OwnerCurrent Issue Owner: @tienifr

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 8, 2024
  2. melvin-bot commented on Apr 8, 2024

    @melvin-bot

    Triggered auto assignment to @isabelastisser (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

  3. lanitochka17 commented on Apr 8, 2024

    @lanitochka17
    Author

    @isabelastisser FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

  4. bernhardoj commented on Apr 9, 2024

    @bernhardoj
    Contributor

    Proposal

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

    There are 2 error message shown, form error and the server validation error.

    What is the root cause of that problem?

    We have 2 types of the magic code error and both of them are shown. One is from the local form validation and the other one is from the server validation.

    errorText={formError?.twoFactorAuthCode ?? ''}
    hasError={hasError}
    autoFocus
    key="twoFactorAuthCode"
    />
    )}
    {hasError && <FormHelpMessage message={ErrorUtils.getLatestErrorMessage(account)} />}

    Also, I think the code isn't shown in the magic code input is a bit weird.

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

    Clear the server error when submitting the magic code.

    if (account?.errors) {
        SessionActions.clearAccountMessages();
    }
    

    If we want to show the magic code when using the magic link, we need to save the code optimistically, currently, we do it when the request is successful.

    {
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.CREDENTIALS,
    value: {
    accountID,
    validateCode,
    },
    },

    Then, we need to update this effect so it updates the code every time the validateCode is updated and loading.

    useEffect(() => {
    if (!!prevValidateCode || !credentials?.validateCode) {
    return;
    }
    setValidateCode(credentials.validateCode);
    }, [credentials?.validateCode, prevValidateCode]);

    useEffect(() => {
        if (!isValidateCodeFormSubmitting) return
        setValidateCode(credentials?.validateCode ?? '');
    }, [isValidateCodeFormSubmitting, credentials?.validateCode]);
    

    What alternative solutions did you explore? (Optional)

  5. added
    ExternalAdded to denote the issue can be worked on by a contributor
    Help WantedApply this label when an issue is open to proposals by contributors
    on Apr 10, 2024
  6. changed the title [-]Android - Enter magic code error is displayed simultaneously with incorrect code error[/-] [+][$250] Android - Enter magic code error is displayed simultaneously with incorrect code error[/+] on Apr 10, 2024
  7. melvin-bot commented on Apr 10, 2024

    @melvin-bot
  8. melvin-bot commented on Apr 10, 2024

    @melvin-bot

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

  9. tienifr commented on Apr 11, 2024

    @tienifr
    Contributor

    Proposal

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

    The user encounters the first error message ("Please enter your magic code") despite having just used the expired magic code link (equivalent to a magic code). Both errors regarding incorrect and entering the magic code are displayed simultaneously

    What is the root cause of that problem?

    There're 2 places we're showing the error:

    • Client validation error here
    • Server error here

    The problem here is that when there's invalid magic code, there's server error, and then when the user clicks Sign in, there's client validation error because there's no magic code in the input, thus this will show both errors at the same time.

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

    1. Clear the server error when we submit the code, in here

    We can use similar logic to clear as here.

    1. Vice versa, we should also clear the client validation error if the server side error appears, this is because if the client error appears first, then the server side error appears, there'll still be 2 errors showing.

    So we should add here

    useEffect(() => {
        if (!hasError) {
            return;
        }
    
        setFormError({});
    }, [hasError]);
    

    (We can make this more specific by only clearing the form error corresponding to the code screen we're showing, also to run the effect only if hasError changes from false to true)

    I think the rest of the UX currently is good, we don't need to show the magic code when using the magic link, because we should let the user be able to type a new code as soon as possible instead of forcing them to delete the invalid code first before entering the new code.

    If we want to fix this UX, it's likely out of this issue's scope. To do it, we can save the code optimistically when submitting the request, and update the code in the UI to match that optimistic code we stored from the magic link.

    What alternative solutions did you explore? (Optional)

    NA

  10. hoangzinh commented on Apr 14, 2024

    @hoangzinh
    Contributor

    Thanks for proposals everyone, @tienifr do you have a test step to reproduce this bug?

    Vice versa, we should also clear the client validation error if the server side error appears, this is because if the client error appears first, then the server side error appears, there'll still be 2 errors showing

  11. isabelastisser commented on Apr 15, 2024

    @isabelastisser
    Contributor
  12. 32 remaining items

  13. isabelastisser commented on May 13, 2024

    @isabelastisser
    Contributor

    Not overdue.

  14. isabelastisser commented on May 17, 2024

    @isabelastisser
    Contributor

    @hoangzinh @marcochavezf can I process the payments? Any regressions?

  15. hoangzinh commented on May 20, 2024

    @hoangzinh
    Contributor

    Yes, please. No regressions so far but wait until I complete the bug zero checklist

  16. hoangzinh commented on May 20, 2024

    @hoangzinh
    Contributor

    BugZero Checklist:

    • The PR that introduced the bug has been identified. Link to the PR: I think it's a new requirement that we haven't covered yet. So no offending PR in this issue.
    • The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment: N/A
    • A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion: N/A
    • Determine if we should create a regression test for this bug: NO, it's an edge case and a UI improvement
  17. isabelastisser commented on May 20, 2024

    @isabelastisser
    Contributor

    Payment summary:

    C+ review @hoangzinh $250, paid in Upwork
    Contributor @tienifr $250, paid in Upwork

    @tienifr, what's your Upwork profile so I can send the offer? Thanks!

  18. tienifr commented on May 21, 2024

    @tienifr
    Contributor
  19. isabelastisser commented on May 21, 2024

    @isabelastisser
    Contributor

    Thanks, the offer was sent.

    All set!

  20. tienifr commented on May 21, 2024

    @tienifr
    Contributor

    Thanks, the offer was sent.

    @isabelastisser Thanks, I accepted it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions