Skip to content

[HOLD for payment 2024-11-13] [HOLD for payment 2024-11-11] Validate account - Need to click "Didn't receive a magic code?" twice to restart timer #51797

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

Closed
3 of 8 tasks
lanitochka17 opened this issue Oct 31, 2024 · 22 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Engineering Weekly KSv2

Comments

@lanitochka17
Copy link

lanitochka17 commented Oct 31, 2024

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.56-0
Reproducible in staging?: Y
Reproducible in production?: No, New feature
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
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team

Issue found when executing PR #51663

Action Performed:

  1. Go to staging.new.expensify.com
  2. Sign up with a new Gmail account
  3. Go to Account settings > Profile
  4. Go to Contact method
  5. Click on the email
  6. Wait 30 seconds
  7. Click "Didn't receive a magic code?" link one time

Expected Result:

Timer will restart after clicking "Didn't receive a magic code?" for the first time

Actual Result:

Timer only restarts after clicking "Didn't receive a magic code?" for the second 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
Bug6651149_1730381279823.20241031_212358.mp4

View all open jobs on GitHub

@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Oct 31, 2024
Copy link

melvin-bot bot commented Oct 31, 2024

Triggered auto assignment to @nkuoch (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Oct 31, 2024

💬 A slack conversation has been started in #expensify-open-source

Copy link
Contributor

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@lanitochka17
Copy link
Author

Production:

bandicam.2024-10-31.16-45-48-403.mp4

@MuaazArshad
Copy link
Contributor

MuaazArshad commented Oct 31, 2024

Proposal

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

Validate account - Need to click "Didn't receive a magic code?" twice to restart timer

What is the root cause of that problem?

We are adding this check

 if (hasMagicCodeBeenSent && !isResent) {
            return;
        }

where hasMagicCodeBeenSent and !isResent are not being before updated with the first click.
They update after the first click, so the timer resets on the second click.

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

This should be removed from

if (hasMagicCodeBeenSent && !isResent) {
return;
}

since we aren’t including it on the sign-in page.
const resendValidateCode = () => {
User.resendValidateCode(credentials?.login ?? '');
inputValidateCodeRef.current?.clear();
// Give feedback to the user to let them know the email was sent so that they don't spam the button.
setTimeRemaining(CONST.REQUEST_CODE_DELAY);
};

The function should run without the condition since there’s no button to click after the code is resent.

What alternative solutions did you explore? (Optional)

@ShridharGoel
Copy link
Contributor

ShridharGoel commented Nov 1, 2024

Edited by proposal-police: This proposal was edited at 2024-11-01 03:15:39 UTC.

Proposal

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

Validate account - Need to click "Didn't receive a magic code?" twice to restart timer.

What is the root cause of that problem?

In the below condition, we check for hasMagicCodeBeenSent and !isResent.

if (hasMagicCodeBeenSent && !isResent) {
return;
}

This is faulty because isResent will become true on using the resend option for the first time, which will eventually lead to no resending on the first click. But the second time, hasMagicCodeBeenSent is false which makes the whole condition false and the code gets sent.

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

To fix this, we need to change the condition to this:

if (hasMagicCodeBeenSent && isResent) {
    return;
}

We also need to update isResent value here, when the timer completes:

useEffect(() => {
    if (timeRemaining > 0) {
        timerRef.current = setTimeout(() => {
            setTimeRemaining(timeRemaining - 1);
        }, 1000);
+    } else {
+       setIsResent(false);
+    }
    return () => {
        clearTimeout(timerRef.current);
    };
}, [timeRemaining]);

We can also evaluate if we need to implement some changes in the way this system works on the sign in page.

@daledah
Copy link
Contributor

daledah commented Nov 1, 2024

Proposal

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

Timer only restarts after clicking "Didn't receive a magic code?" for the second time

What is the root cause of that problem?

In resentValidateCode, we check the following condition:

if (hasMagicCodeBeenSent && !isResent) {
return;
}

However, resentValidateCode is called before isResent becomes true:

resendValidateCode();
setIsResent(true);

Results in the resend logic not being called the first time.

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

Instead of state, make isResent a ref:

const isResentRef = useRef(false)

And update related logics:

if (hasMagicCodeBeenSent && !isResent) {
return;
}

        if (hasMagicCodeBeenSent && !isResentRef.current) {
            return;
        }
        isResentRef.current = false;

onPress={() => {
resendValidateCode();
setIsResent(true);
}}

    onPress={() => {
        isResentRef.current = true;
        resendValidateCode();
    }}

What alternative solutions did you explore? (Optional)

@Beamanator
Copy link
Contributor

Thanks your proposals so far, everyone! Can anyone find which PR may have caused this?

@ShridharGoel
Copy link
Contributor

#51663

@hungvu193
Copy link
Contributor

cc @getusha

@ShridharGoel
Copy link
Contributor

Any plans to make this external?

@hungvu193
Copy link
Contributor

It's still in the regression period so I think @getusha will handle it.

@Beamanator Please assign me and @getusha.

@ShridharGoel
Copy link
Contributor

You can have a look at my proposal: #51797 (comment)

It might help.

@mountiny
Copy link
Contributor

mountiny commented Nov 1, 2024

Thanks! @getusha and @hungvu193 should handle this one

@Beamanator
Copy link
Contributor

thanks @vitHoracek :D

@mountiny
Copy link
Contributor

mountiny commented Nov 1, 2024

NoProblem @alexBeaman

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Hourly KSv2 labels Nov 1, 2024
@Beamanator
Copy link
Contributor

Merged & CPing

@Beamanator
Copy link
Contributor

Seems to be working in staging! Checking it off!

@Beamanator Beamanator removed Reviewing Has a PR in review DeployBlockerCash This issue or pull request should block deployment labels Nov 4, 2024
@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Nov 4, 2024
@melvin-bot melvin-bot bot changed the title Validate account - Need to click "Didn't receive a magic code?" twice to restart timer [HOLD for payment 2024-11-11] Validate account - Need to click "Didn't receive a magic code?" twice to restart timer Nov 4, 2024
Copy link

melvin-bot bot commented Nov 4, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.56-9 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-11-11. 🎊

For reference, here are some details about the assignees on this issue:

  • @hungvu193 requires payment through NewDot Manual Requests
  • @getusha requires payment through NewDot Manual Requests

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Nov 6, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-11-11] Validate account - Need to click "Didn't receive a magic code?" twice to restart timer [HOLD for payment 2024-11-13] [HOLD for payment 2024-11-11] Validate account - Need to click "Didn't receive a magic code?" twice to restart timer Nov 6, 2024
Copy link

melvin-bot bot commented Nov 6, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.57-10 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-11-13. 🎊

For reference, here are some details about the assignees on this issue:

  • @hungvu193 requires payment through NewDot Manual Requests
  • @getusha requires payment through NewDot Manual Requests

Copy link

melvin-bot bot commented Nov 13, 2024

Issue is ready for payment but no BZ is assigned. @twisterdotcom you are the lucky winner! Please verify the payment summary looks correct and complete the checklist. Thanks!

Copy link

melvin-bot bot commented Nov 13, 2024

Payment Summary

Upwork Job

BugZero Checklist (@twisterdotcom)

  • I have verified the correct assignees and roles are listed above and updated the neccesary manual offers
  • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
  • I have paid out the Upwork contracts or cancelled the ones that are incorrect
  • I have verified the payment summary above is correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Engineering Weekly KSv2
Projects
None yet
Development

No branches or pull requests

10 participants