You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Awaiting checklist] [$250] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup #50695
Version Number: 9.0.48-0 Reproducible in staging?: Y Reproducible in production?: Y Email or phone of affected tester (no customers):applausetester+kh081006@applause.expensifail.com Issue reported by: Applause Internal Team
@twisterdotcom 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
Edited by proposal-police: This proposal was edited at 2024-10-20 17:59:03 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
When connecting to Xero, after opening the two-factor authentication modal and tapping the back button multiple times, the app stays in the Accounting page instead returning to the expected Workspace list.
This issue does not occur when connecting to NetSuite, and others, where the navigation behaves as expected.
just write: onBackButtonPress={() => TwoFactorAuthActions.quitAndNavigateBack()}
this change solve the issue mentioned in the OP, and does not cause any regression for 2FA used in the Security page,.
How does the above change work when visiting 2FA page directly via URL - How is the accounting page added as the backTo in the navigation stack?
When we open the 2FA page directly through the URL with the backTo parameter, the app still knows where to go back because:
The URL's backTo parameter (settings/workspaces/{workspaceId}/accounting) is processed by getMatchingRootRouteForRHPRoute function, which:
Takes this URL and converts it to a navigation state using getStateFromPath(route.params.backTo, config)
Checks for the target screen type (RHP navigator, full screen navigator, or central pane screen)
In our case, it finds that the accounting page is FullScreenNavigator
The app then uses this information to set up the correct navigation stack, even though we didn't navigate there step by step. This happens in the getAdaptedState function, which:
Sets up the proper bottom tab navigator
Adds the matching central pane route (accounting page in our case)
Adds the RHP navigator (2FA screen)
So even when accessing the 2FA page directly, the backTo parameter helps the app reconstruct the proper navigation stack context. That's why when we click the back button (which calls navigation.goBack()), it knows to take us back to the accounting page.
We can actually verify this behavior by testing: if we remove the backTo parameter from the URL, the back navigation won't work as expected because the app won't have the information needed to reconstruct the proper navigation stack. This is because the logic in getMatchingRootRouteForRHPRoute specifically checks for and relies on this parameter:
if(route.params&&'backTo'inroute.params&&typeofroute.params.backTo==='string'){conststateForBackTo=getStateFromPath(route.params.backTo,config);if(stateForBackTo){// If we know that backTo targets the root route (full screen) we want to use it.constfullScreenNavigator=stateForBackTo.routes.find((rt)=>rt.name===NAVIGATORS.FULL_SCREEN_NAVIGATOR);if(fullScreenNavigator&&fullScreenNavigator.state){returnfullScreenNavigatorasNavigationPartialRoute<CentralPaneName|typeofNAVIGATORS.FULL_SCREEN_NAVIGATOR>;}}}
FullScreenNavigator will have settings/workspaces/{workspaceId}/accounting as path with it.
Note: For better verification, we can add a breakpoint at getMatchingRootRouteForRHPRoute function and access the page with the direct URL (https://dev.new.expensify.com:8082/settings/security/two-factor-auth?backTo=settings%2Fworkspaces%2F{workspaceId}%2Faccounting&forwardTo=https%3A%2F%2Fwww.expensify.com%2Fapi%2FConnectPolicyToXero%3FpolicyID%3D{workspaceId}) - this will let us inspect exactly how the backTo parameter is being processed.
changed the title [-] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/-][+][$250] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/+]on Oct 14, 2024
which will replace the 2FA route with the accounting page. That will create a duplicate workspace accounting route to the navigation state.
What changes do you think we should make in order to solve the problem?
Instead of navigating to the fallBackRoute here with Replace action we should goBack, which will play the role of REPLACE action we were using, and then navigate to the fallbackRoute
This will create the same effect as the navigating with REPLACE and whenever the fallbackRoute is the same as the route we are going back to it will not create a duplicate route in the navigation state and instead leave it.
What alternative solutions did you explore? (Optional)
because we navigate to ROUTES.SETTINGS_2FA from different flows we need it for other cases
This will work for direct link access too because whenever full screen navigator is found in the state found from backTo of the route we add the necessary full navigator here
changed the title [-][$250] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/-][+][HOLD for payment 2024-11-22] [$250] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/+]on Nov 15, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.62-4 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@hoangzinh@twisterdotcom@hoangzinh The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
changed the title [-][HOLD for payment 2024-11-22] [$250] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/-][+][Awaiting checklist] [$250] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/+]on Nov 22, 2024
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Nope, I think it's just a small UX issue. Users still use the app normally.
Activity
melvin-bot commentedon Oct 13, 2024
Triggered auto assignment to @twisterdotcom (
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.IuliiaHerets commentedon Oct 13, 2024
We think that this bug might be related to #wave-collect - Release 2
IuliiaHerets commentedon Oct 13, 2024
@twisterdotcom 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
Shahidullah-Muffakir commentedon Oct 13, 2024
Edited by proposal-police: This proposal was edited at 2024-10-20 17:59:03 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
we pass the backTo route to it here:
App/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx
Line 64 in 5967584
What changes do you think we should make in order to solve the problem?
We don't need to pass the backTo
App/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx
Line 64 in 5967584
just write:
onBackButtonPress={() => TwoFactorAuthActions.quitAndNavigateBack()}this change solve the issue mentioned in the OP, and does not cause any regression for 2FA used in the Security page,.
How does the above change work when visiting 2FA page directly via URL - How is the accounting page added as the backTo in the navigation stack?
When we open the 2FA page directly through the URL with the
backToparameter, the app still knows where to go back because:The URL's
backToparameter (settings/workspaces/{workspaceId}/accounting) is processed bygetMatchingRootRouteForRHPRoutefunction, which:getStateFromPath(route.params.backTo, config)The app then uses this information to set up the correct navigation stack, even though we didn't navigate there step by step. This happens in the
getAdaptedStatefunction, which:So even when accessing the 2FA page directly, the
backToparameter helps the app reconstruct the proper navigation stack context. That's why when we click the back button (which callsnavigation.goBack()), it knows to take us back to the accounting page.We can actually verify this behavior by testing: if we remove the
backToparameter from the URL, the back navigation won't work as expected because the app won't have the information needed to reconstruct the proper navigation stack. This is because the logic ingetMatchingRootRouteForRHPRoutespecifically checks for and relies on this parameter:FullScreenNavigator will have settings/workspaces/{workspaceId}/accounting as path with it.
App/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts
Lines 127 to 131 in 608ec61
here is all the related code:
App/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts
Lines 116 to 126 in 608ec61
Note: For better verification, we can add a breakpoint at
getMatchingRootRouteForRHPRoutefunction and access the page with the direct URL(https://dev.new.expensify.com:8082/settings/security/two-factor-auth?backTo=settings%2Fworkspaces%2F{workspaceId}%2Faccounting&forwardTo=https%3A%2F%2Fwww.expensify.com%2Fapi%2FConnectPolicyToXero%3FpolicyID%3D{workspaceId})- this will let us inspect exactly how the backTo parameter is being processed.Screen.20Recording.202024-10-20.20at.2011.mp4
iOS
Screen.Recording.2024-10-14.at.12.26.00.AM.mov
NJ-2020 commentedon Oct 14, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Navigation issue when tapping app back button three times after exiting 2FA setup
What is the root cause of that problem?
When we press the go back button inside the TwoFactorAuth page, we invoke this function
App/src/libs/actions/TwoFactorAuthActions.ts
Lines 21 to 24 in 2329c78
We pass the fallback route which leads to this issue
App/src/libs/Navigation/Navigation.ts
Lines 201 to 205 in 2329c78
What changes do you think we should make in order to solve the problem?
Remove the backTo(fallbackRoute)
What alternative solutions did you explore? (Optional)
melvin-bot commentedon Oct 14, 2024
Job added to Upwork: https://www.upwork.com/jobs/~021845826997685288640
[-] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/-][+][$250] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/+]melvin-bot commentedon Oct 14, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @hoangzinh (
External)FitseTLT commentedon Oct 14, 2024
Edited by proposal-police: This proposal was edited at 2024-10-14 20:31:49 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup
What is the root cause of that problem?
When we press back button goBack is called with fallbackRoute
App/src/libs/actions/TwoFactorAuthActions.ts
Line 23 in 8ff185a
but because it is first route in the navigator it will navigate to the fallbackRoute here
App/src/libs/Navigation/Navigation.ts
Line 235 in 8ff185a
which will replace the 2FA route with the accounting page. That will create a duplicate workspace accounting route to the navigation state.
What changes do you think we should make in order to solve the problem?
Instead of navigating to the fallBackRoute here with Replace action we should
goBack, which will play the role ofREPLACEaction we were using, and then navigate to the fallbackRouteApp/src/libs/Navigation/Navigation.ts
Line 235 in 8ff185a
This will create the same effect as the navigating with
REPLACEand whenever the fallbackRoute is the same as the route we are going back to it will not create a duplicate route in the navigation state and instead leave it.What alternative solutions did you explore? (Optional)
We can also avoid having backTo here
App/src/pages/settings/Security/TwoFactorAuth/Steps/CodesStep.tsx
Line 69 in 5103b4b
for the case of Xero so change it to
because we navigate to
ROUTES.SETTINGS_2FAfrom different flows we need it for other casesThis will work for direct link access too because whenever full screen navigator is found in the state found from backTo of the route we add the necessary full navigator here
App/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts
Lines 127 to 132 in 5103b4b
and as we will not remove the backTo from the route it will work perfect.
42 remaining items
[-][$250] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/-][+][HOLD for payment 2024-11-22] [$250] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/+]melvin-bot commentedon Nov 15, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Nov 15, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.62-4 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-22. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Nov 15, 2024
@hoangzinh @twisterdotcom @hoangzinh The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
twisterdotcom commentedon Nov 22, 2024
Payment Summary:
[-][HOLD for payment 2024-11-22] [$250] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/-][+][Awaiting checklist] [$250] iOS Xero - Navigation issue when tapping app back button three times after exiting 2FA setup[/+]hoangzinh commentedon Nov 22, 2024
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] 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: We have an issue to for long term fix this bug already RHP Navigation - Weird
goBackbehaviour #47534[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source 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
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Nope, I think it's just a small UX issue. Users still use the app normally.
garrettmknight commentedon Nov 26, 2024
$250 approved for @hoangzinh