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

[$325] Android - Profile - Add contact method flow resumes at magic code page after killing app #48498

Closed
1 of 6 tasks
lanitochka17 opened this issue Sep 3, 2024 · 39 comments
Closed
1 of 6 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Overdue

Comments

@lanitochka17
Copy link

lanitochka17 commented Sep 3, 2024

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: 9.0.28-1
Reproducible in staging?: Y
Reproducible in production?: N
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): applausetester+kh010901@applause.expensifail.com
Issue reported by: Applause - Internal Team

Action Performed:

  1. Launch New Expensify app
  2. Go to Account settings
  3. Go to Profile > Contact methods
  4. Tap New contact method
  5. Enter email > Next
  6. On magic code page, kill the app
  7. Relaunch the app
  8. Go to Account settings
  9. Go to Profile > Contact methods
  10. Tap New contact method

Expected Result:

Add contact method flow will restart. App will open new contact method input page

Actual Result:

Add contact method flow resumes at magic code page instead of new contact method input page after killing app

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

Bug6592010_1725385884722.1725384996537_Screen_Recording_20240904_003949_New_Expensify.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~017a6ead314da0c17b
  • Upwork Job ID: 1831082861275959824
  • Last Price Increase: 2024-09-20
Issue OwnerCurrent Issue Owner: @parasharrajat
@lanitochka17 lanitochka17 added the DeployBlockerCash This issue or pull request should block deployment label Sep 3, 2024
Copy link

melvin-bot bot commented Sep 3, 2024

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

Copy link
Contributor

github-actions bot commented Sep 3, 2024

👋 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.

@roryabraham
Copy link
Contributor

NAB, demoting.

@roryabraham roryabraham added Daily KSv2 and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Sep 3, 2024
@roryabraham
Copy link
Contributor

For posterity, this was likely introduced in this checklist.

@roryabraham roryabraham added Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor labels Sep 3, 2024
@melvin-bot melvin-bot bot changed the title Android - Profile - Add contact method flow resumes at magic code page after killing app [$250] Android - Profile - Add contact method flow resumes at magic code page after killing app Sep 3, 2024
Copy link

melvin-bot bot commented Sep 3, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 3, 2024
Copy link

melvin-bot bot commented Sep 3, 2024

Triggered auto assignment to @bfitzexpensify (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

melvin-bot bot commented Sep 3, 2024

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

@Krishna2323
Copy link
Contributor

Krishna2323 commented Sep 3, 2024

Edited by proposal-police: This proposal was edited at 2024-09-03 22:23:02 UTC.

Proposal


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

Android - Profile - Add contact method flow resumes at magic code page after killing app

What is the root cause of that problem?

The NewContactMethodPage redirects to SETTINGS_CONTACT_METHOD_VALIDATE_ACTION when pendingContactAction?.validateCodeSent is true. Once the code is sent, pendingContactAction?.validateCodeSent is set to true. Additionally, when the app is closed, the ONYX data is not cleared.

useEffect(() => {
if (!pendingContactAction?.validateCodeSent) {
return;
}
Navigation.navigate(ROUTES.SETINGS_CONTACT_METHOD_VALIDATE_ACTION);
}, [pendingContactAction]);

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


  • We should add a useEffect in the ContactMethodsPage which will call User.clearUnvalidatedNewContactMethodAction(), this will clear the ONYX data related to PENDING_CONTACT_ACTION. Or it can be added in AuthScreens.tsx
    useEffect(() => {
        User.clearUnvalidatedNewContactMethodAction();
    }, []);

What alternative solutions did you explore? (Optional)

We can add a useEffect cleanup function to call User.clearUnvalidatedNewContactMethodAction(); when component unmounts.

What alternative solutions did you explore? (Optional) 2

  • We can call User.clearUnvalidatedNewContactMethodAction() when New contact method button is pressed.
    const onNewContactMethodButtonPress = useCallback(() => {
    Navigation.navigate(ROUTES.SETTINGS_NEW_CONTACT_METHOD.getRoute(navigateBackTo));
    }, [navigateBackTo]);

Result

@Krishna2323
Copy link
Contributor

Proposal Updated

  • Added alternative 2

@nkdengineer
Copy link
Contributor

Proposal

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

Add contact method flow resumes at magic code page instead of new contact method input page after killing app

What is the root cause of that problem?

When we kill the app the cleanup function here isn't triggered then if we requested the magic code before killing the App, this useEffect will redirect the user to the magic code page

useEffect(() => {
if (!pendingContactAction?.validateCodeSent) {
return;
}
Navigation.navigate(ROUTES.SETINGS_CONTACT_METHOD_VALIDATE_ACTION);
}, [pendingContactAction]);

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

  • If it's expected that we want to continue the current step after we kill the app or close the validate code page without clicking on back button we can remove this cleanup function

useEffect(() => () => User.clearUnvalidatedNewContactMethodAction(), []);

  • Otherwise, I think we can remove this useEffect because I don't see any case that we need this logic.

OPTIONAL: we can also change the cleanup function here to clear the pending contact method whenever the NewContactMethodPage is mounted. It also can be unnecessary because when we submit this form the pending contact method data is also reset

useEffect(() => {
if (!pendingContactAction?.validateCodeSent) {
return;
}
Navigation.navigate(ROUTES.SETINGS_CONTACT_METHOD_VALIDATE_ACTION);
}, [pendingContactAction]);

What alternative solutions did you explore? (Optional)

@parasharrajat
Copy link
Member

Analyzing the correct behaviour...

@parasharrajat
Copy link
Member

IMO the behaviour should be as follows:

  1. when the user refreshes the validate code page, it lands on the same validate input given that the validation flow was in progress.
  2. When user press back button or closes the flow via dismiss the modal or etc, the flow cancels. Clicking new contact should initiate the new flow.

What do you think @Krishna2323 @nkdengineer ?

@Krishna2323
Copy link
Contributor

Krishna2323 commented Sep 4, 2024

@parasharrajat, yep, that sounds accurate to me.

I think my alternative solution 2 will fix the issue with the expected behaviour. Then we can also remove this and this code.

@roryabraham
Copy link
Contributor

Agree with @parasharrajat's analysis of the expected behavior

@parasharrajat
Copy link
Member

Let's go with @Krishna2323's alternative solution 2 for this, then. let's keep the cleanup login on the back button press.

We might have to handle a case.

  1. User on validate contact page.
  2. He dismisses the modal.
    3 Now landing on new contact page directly should not show validate code page as user dismissed it.

@Krishna2323 thoughts.

@bfitzexpensify
Copy link
Contributor

I am heading out of office until September 21st, so assigning a buddy to watch over this in my absence.

Current status: working through proposals

@Krishna2323
Copy link
Contributor

@parasharrajat, I think dismissing the modal will clear the data and the validate code page won't be shown when directly visiting. I agree to keep the clear cleanup login.

@parasharrajat
Copy link
Member

OK. What about the page refresh? If we keep the cleanup logic as it is now, How will it work in that case?

Can you please explain the behaviour of all cases as mentioned in #48498 (comment) after applying your solution?

@Krishna2323
Copy link
Contributor

Full Page Refresh (F5 or Browser Refresh Button): In this case, the page is completely reloaded, and the React component tree is destroyed. However, React will not get a chance to run the cleanup function because the entire page is reloaded by the browser, effectively bypassing React's lifecycle methods.

  1. when the user refreshes the validate code page, it lands on the same validate input given that the validation flow was in progress.

@parasharrajat, according to the above point and my testing, the cleanup function will not run when we refresh the page, so we will land on the same validate code if we refresh.

  1. When user press back button or closes the flow via dismiss the modal or etc, the flow cancels. Clicking new contact should initiate the new flow.
  • If the user presses the back button or dismisses the modal, the flow will be canceled by calling User.clearUnvalidatedNewContactMethodAction();.
  • When quitting the page during the contact method flow and starting the flow again, pressing the "New Contact" button will trigger User.clearUnvalidatedNewContactMethodAction(); and new flow will be initiated.

@parasharrajat
Copy link
Member

parasharrajat commented Sep 9, 2024

the cleanup function will not run when we refresh the page, so we will land on the same validate code if we refresh.

Did you try it twice? Does this this work for each page refresh?

When quitting the page during the contact method flow and starting the flow again, pressing the "New Contact" button will trigger User.clearUnvalidatedNewContactMethodAction(); and new flow will be initiated.

What if user does not start the flow via new Contact Button, we do that directly via the URL. Will this work?

@Krishna2323
Copy link
Contributor

Did you try it twice? Does this this work for each page refresh?

Yes, it will work.

What if user does not start the flow via new Contact Button, we do that directly via the URL. Will this work?

I think we should show the validate code page in this case also.

Monosnap.screencast.2024-09-09.14-11-26.mp4

@parasharrajat
Copy link
Member

What if user does not start the flow via new Contact Button, we do that directly via the URL. Will this work?

It should be as follows:

  1. A user initiates a flow and does not close it either via a back button or dismissing the modal, navigating to that page via refresh or directly opens the validate code page.
  2. If user cancels the flow by any action, navigating to that page will show a fresh flow.

Does that make sense?

@Krishna2323
Copy link
Contributor

@parasharrajat, sorry I still couldn't understand what do you mean.

Are you trying to say that we want to initiate a new flow when the user closes the web page on the validate code page and opens it again with the url?

Copy link

melvin-bot bot commented Sep 10, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@parasharrajat
Copy link
Member

I am saying that we initiate the new flow when the user closes the page via a back button or dismisses the modal (Any other actions that indicate that the user has closed the flow themselves). But page refresh is not one of them. Refreshing the page continues the same flow.

@Krishna2323
Copy link
Contributor

Refreshing the page continues the same flow.

I agree with that and that's what I tried to show in the video below. Refreshing the page continues the same flow.

Monosnap.screencast.2024-09-09.14-11-26.mp4

@parasharrajat
Copy link
Member

that's good. Now what happens if you close the modal by clicking outside the modal and then directly open the URL?

Copy link

melvin-bot bot commented Sep 13, 2024

@CortneyOfstad, @parasharrajat, @bfitzexpensify, @roryabraham Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Sep 13, 2024
@parasharrajat
Copy link
Member

@Krishna2323 Any thoughts?

@melvin-bot melvin-bot bot removed the Overdue label Sep 16, 2024
Copy link

melvin-bot bot commented Sep 17, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

Copy link

melvin-bot bot commented Sep 17, 2024

@CortneyOfstad @parasharrajat @bfitzexpensify @roryabraham this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

@CortneyOfstad
Copy link
Contributor

@Krishna2323 — bump @parasharrajat's comment above — thanks!

@melvin-bot melvin-bot bot added the Overdue label Sep 18, 2024
Copy link

melvin-bot bot commented Sep 19, 2024

@CortneyOfstad, @parasharrajat, @bfitzexpensify, @roryabraham Whoops! This issue is 2 days overdue. Let's get this updated quick!

@roryabraham roryabraham changed the title [$250] Android - Profile - Add contact method flow resumes at magic code page after killing app [$325] Android - Profile - Add contact method flow resumes at magic code page after killing app Sep 20, 2024
Copy link

melvin-bot bot commented Sep 20, 2024

Upwork job price has been updated to $325

@rushatgabhane
Copy link
Member

rushatgabhane commented Sep 20, 2024

regression from #48541 (comment) @hungvu193 @getusha

@hungvu193
Copy link
Contributor

hungvu193 commented Sep 20, 2024

Thanks for the ping @rushatgabhane.
I remembered I had already removed the usage of ValidateContactActionPage in this PR (#48628).
We switched to using ValdiateCodeModal and using local state to handle modal state so I think this issue is fixed.

@hungvu193
Copy link
Contributor

I can confirm it's fixed. We can close this issue:

Screen.Recording.2024-09-20.at.09.25.51.mov

@melvin-bot melvin-bot bot removed the Overdue label Sep 20, 2024
@roryabraham roryabraham added Overdue and removed Help Wanted Apply this label when an issue is open to proposals by contributors labels Sep 20, 2024
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. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Overdue
Projects
No open projects
Status: No status
Development

No branches or pull requests

9 participants