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
[READY for payment 2025-01-02] [$250] Hybrid - Android - WS Switcher - App is closed when switching workspace and using device back button. #53533
Version Number: 9.0.71-0 Reproducible in staging?: Yes Reproducible in production?: No If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: No, reproducible on hybrid only 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):ibellicotest+73@gmail.com Issue reported by: Applause Internal Team
Action Performed:
Launch the Expensify app.
Tap on the workspace switcher on the top left corner.
Select any workspace.
Use the device back button.
Verify that now all the chats are displayed again on inbox.
Expected Result:
After switching workspaces and using device back button, all the chats should be displayed again on inbox.
Actual Result:
The app is closed instead of displaying all chats again, when the user switch workspaces and uses device back button. When the app is reopened, all chats are displayed in inbox.
changed the title [-]Hybrid - Android - WS Switcher - App is closed when switching workspace and using device back button.[/-][+][$250] Hybrid - Android - WS Switcher - App is closed when switching workspace and using device back button.[/+]on Dec 6, 2024
Please re-state the problem that we are trying to solve in this issue
When the user switches to a specific workspace chats and then uses device back button, the app is closed instead of displaying all chats again (Expensify).
What is the root cause of that problem?
Note
The issue is present on Android: Native as well as on Android: HybridApp (more details below).
In the WorkspaceSwitcherPage we have the selectPolicy function which is called when we switch to a specific workspace chats. If we follow Navigation.navigateWithSwitchPolicyID down to source we arrive to the switchPolicyID function where at the bottom we get to the root cause of why, when we use the device back button the app will close instead of returning back to all chats (Expensify):
Because that block pops all central pane routes out in order for the bottom tab navigator to be visible, this means that the only route present in the stack is BottomTabNavigator which is the same as when we open the app -> which when pressing hardware / device back button it will close the app as expected because there's no other route to go back to.
What's the code responsible for handling the hardware / device back button and close the app on Android ?
We have this android platform specific function setupCustomAndroidBackHandler which is used to dictate the behaviour and if we look at its code, there is this block which is Android: HybridApp specific that tells the app to close when isLastScreenOnStack is true which is the case for our issue:
For Android: Native though we don't have any code in this function to specifically handle behaviour, therefore it defaults to the standard behaviour (close the app) at the end of the function:
isWorkspaceHomeOnlyRoute checks whether in bottomTabRoutes (array) every Home route has the policyID param
If isLastScreenOnStack and isWorkspaceHomeOnlyRoute are both true - this will always be the case when we are on the specific workspace chats home screen since there is only one route in the stack and it is the Home route with policyID param
When we go back with device back button and this condition is true -> we will replace the Home screen with policyID param with the Home screen without any params, which is the Expensify home page with all chats.
This will fix the issue as required by the Expected result (see video below) because when we will perform the go back action we will have the Home screen in the stack and will be navigated to Home (all chats), then if we go back again from Home then the app will close as expected.
Additional explanation regarding Android: HybridApp -> under the new logic added above we will keep the Android: HybridApplogic unchanged since in case the newly added condition doesn't pass it means we want to keep the existing NativeModules.HybridAppModule.exitApp() logic because without this I assume the app will not close as the Android: Native app does by default.
cc @adamgrzybowski@Kicu for a take on the proposed solution as they worked on setupCustomAndroidBackHandler
The root cause is the use of the Replace navigation method instead of Push.
When switching to another workspace and pressing the back button, the app closes because the stack contains only one entry, which triggers this condition.
What changes do you think we should make in order to solve the problem?
When switching workspaces from WorkspaceSwitcherPage, we should use the Push navigation method instead of Replace. To implement we need:
[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.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
changed the title [-][HOLD for payment 2025-01-02] [$250] Hybrid - Android - WS Switcher - App is closed when switching workspace and using device back button.[/-][+][READY for payment 2025-01-02] [$250] Hybrid - Android - WS Switcher - App is closed when switching workspace and using device back button.[/+]on Jan 9, 2025
Activity
melvin-bot commentedon Dec 4, 2024
Triggered auto assignment to @RachCHopkins (
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.RachCHopkins commentedon Dec 6, 2024
Can Repro - When I hit the device back button it closes the app entirely. I am on 9.0.71-1
[-]Hybrid - Android - WS Switcher - App is closed when switching workspace and using device back button.[/-][+][$250] Hybrid - Android - WS Switcher - App is closed when switching workspace and using device back button.[/+]melvin-bot commentedon Dec 6, 2024
Job added to Upwork: https://www.upwork.com/jobs/~021864885051135538956
melvin-bot commentedon Dec 6, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eh2077 (
External)ikevin127 commentedon Dec 8, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue
When the user switches to a specific workspace chats and then uses device back button, the app is closed instead of displaying all chats again (Expensify).
What is the root cause of that problem?
Note
The issue is present on Android: Native as well as on Android: HybridApp (more details below).
In the
WorkspaceSwitcherPagewe have theselectPolicyfunction which is called when we switch to a specific workspace chats. If we followNavigation.navigateWithSwitchPolicyIDdown to source we arrive to theswitchPolicyIDfunction where at the bottom we get to the root cause of why, when we use the device back button the app will close instead of returning back to all chats (Expensify):App/src/libs/Navigation/switchPolicyID.ts
Lines 150 to 156 in b595f5d
as this block comes into action on narrow layout devices because of this condition:
App/src/libs/Navigation/switchPolicyID.ts
Lines 115 to 116 in b595f5d
Because that block pops all central pane routes out in order for the bottom tab navigator to be visible, this means that the only route present in the stack is
BottomTabNavigatorwhich is the same as when we open the app -> which when pressing hardware / device back button it will close the app as expected because there's no other route to go back to.What's the code responsible for handling the hardware / device back button and close the app on Android ?
We have this android platform specific function
setupCustomAndroidBackHandlerwhich is used to dictate the behaviour and if we look at its code, there is this block which is Android: HybridApp specific that tells the app to close whenisLastScreenOnStackistruewhich is the case for our issue:App/src/libs/Navigation/setupCustomAndroidBackHandler/index.android.ts
Lines 27 to 29 in b595f5d
For Android: Native though we don't have any code in this function to specifically handle behaviour, therefore it defaults to the standard behaviour (close the app) at the end of the function:
App/src/libs/Navigation/setupCustomAndroidBackHandler/index.android.ts
Lines 66 to 67 in b595f5d
What changes do you think we should make in order to solve the problem?
To solve our issue on both Android: Native and HybridApp we have to implement the following changes:
App/src/libs/Navigation/setupCustomAndroidBackHandler/index.android.ts
Line 25 in b595f5d
add the following logic:
Explanation
isWorkspaceHomeOnlyRoutechecks whether inbottomTabRoutes(array) every Home route has thepolicyIDparamisLastScreenOnStackandisWorkspaceHomeOnlyRouteare bothtrue- this will always be the case when we are on the specific workspace chats home screen since there is only one route in the stack and it is the Home route withpolicyIDparamtrue-> we will replace the Home screen withpolicyIDparam with the Home screen without any params, which is the Expensify home page with all chats.This will fix the issue as required by the Expected result (see video below) because when we will perform the go back action we will have the Home screen in the stack and will be navigated to Home (all chats), then if we go back again from Home then the app will close as expected.
Additional explanation regarding Android: HybridApp -> under the new logic added above we will keep the Android: HybridApp logic unchanged since in case the newly added condition doesn't pass it means we want to keep the existing
NativeModules.HybridAppModule.exitApp()logic because without this I assume the app will not close as the Android: Native app does by default.cc @adamgrzybowski @Kicu for a take on the proposed solution as they worked on
setupCustomAndroidBackHandlerResult video (before / after)
Android: Native
before.mp4
after.mp4
linhvovan29546 commentedon Dec 9, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
Android - WS Switcher - App is closed when switching workspace and using device back button.
What is the root cause of that problem?
Replacenavigation method instead ofPush.What changes do you think we should make in order to solve the problem?
WorkspaceSwitcherPage, we should use thePushnavigation method instead ofReplace. To implement we need:App/src/libs/Navigation/switchPolicyID.ts
Line 29 in 7925c9b
App/src/libs/Navigation/switchPolicyID.ts
Line 76 in 7925c9b
App/src/libs/Navigation/switchPolicyID.ts
Line 102 in 7925c9b
App/src/libs/Navigation/switchPolicyID.ts
Line 29 in 7925c9b
shouldReplaceHome: false.Pushinstead ofReplacewhen called from this screen.Results
### Demo Videosback-button-before.mp4
back-button-after.mp4
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Because this issue come from this, we need to check other related cases.
What alternative solutions did you explore? (Optional)
N/A
45 remaining items
RachCHopkins commentedon Dec 31, 2024
Contributor to be paid via newdot, there is no contract to complete, and the Upwork post has been closed.
melvin-bot commentedon Jan 2, 2025
Payment Summary
Upwork Job
BugZero Checklist (@RachCHopkins)
eh2077 commentedon Jan 2, 2025
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: https://github.com/Expensify/App/pull/49937/files#r1900980891
[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.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/459146
Regression Test Proposal
Precondition:
Test:
Blank HomeScreen fix
App closing when going back after switching workspace
Search page briefly goes blank when switching workspace
Do we agree 👍 or 👎
melvin-bot commentedon Jan 7, 2025
@chrispader, @RachCHopkins, @mountiny, @eh2077 Eep! 4 days overdue now. Issues have feelings too...
RachCHopkins commentedon Jan 8, 2025
Sorry team, will get this paid out asap - it was hiding due to a filter at my end!
[-][HOLD for payment 2025-01-02] [$250] Hybrid - Android - WS Switcher - App is closed when switching workspace and using device back button.[/-][+][READY for payment 2025-01-02] [$250] Hybrid - Android - WS Switcher - App is closed when switching workspace and using device back button.[/+]RachCHopkins commentedon Jan 10, 2025
Payment Summary:
Contributor: @chrispader - no payment due (contractor)
Contributor+: @eh2077 to bepaid $250 via NewDot Manual Request.
Upwork job here
RachCHopkins commentedon Jan 10, 2025
Contributor is to be paid via Newdot, there is no contract to complete, and the Upwork post has been closed.
JmillsExpensify commentedon Jan 10, 2025
$250 approved for @eh2077