Skip to content

[READY for payment 2025-01-02] [$250] Hybrid - Android - WS Switcher - App is closed when switching workspace and using device back button. #53533

Closed

Description

@IuliiaHerets

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

  1. Launch the Expensify app.
  2. Tap on the workspace switcher on the top left corner.
  3. Select any workspace.
  4. Use the device back button.
  5. 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.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Bug6683901_1733291014764.WS_Switch.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021864885051135538956
  • Upwork Job ID: 1864885051135538956
  • Last Price Increase: 2024-12-06
Issue OwnerCurrent Issue Owner: @RachCHopkins

Activity

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

    @melvin-bot

    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.

  3. RachCHopkins commented on Dec 6, 2024

    @RachCHopkins
    Contributor

    Can Repro - When I hit the device back button it closes the app entirely. I am on 9.0.71-1

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Dec 6, 2024
  5. 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
  6. melvin-bot commented on Dec 6, 2024

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 6, 2024
  8. melvin-bot commented on Dec 6, 2024

    @melvin-bot

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

  9. ikevin127 commented on Dec 8, 2024

    @ikevin127
    Contributor

    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 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):

    } else {
    // If the layout is small we need to pop everything from the central pane so the bottom tab navigator is visible.
    root.dispatch({
    type: 'POP_TO_TOP',
    target: rootState.key,
    });
    }

    as this block comes into action on narrow layout devices because of this condition:

    // The correct route for SearchPage is located in the CentralPane
    const shouldAddToCentralPane = !getIsNarrowLayout() || isOpeningSearchFromBottomTab;

    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:

    if (NativeModules.HybridAppModule && isLastScreenOnStack) {
    NativeModules.HybridAppModule.exitApp();
    }

    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:

    // Handle all other cases with default handler.
    return false;

    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:

    1. Under:
      const isLastScreenOnStack = bottomTabRoutes.length === 1 && rootState?.routes?.length === 1;

    add the following logic:

    const isWorkspaceHomeOnlyRoute = bottomTabRoutes.every((route) => route.name === SCREENS.HOME && !!(route.params as {policyID?: string})?.policyID);
    
    if (isLastScreenOnStack && isWorkspaceHomeOnlyRoute) {
        navigationRef.dispatch({...StackActions.replace(SCREENS.HOME)});
        return true;
    }

    Explanation

    1. isWorkspaceHomeOnlyRoute checks whether in bottomTabRoutes (array) every Home route has the policyID param
    2. 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
    3. 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: 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 setupCustomAndroidBackHandler

    Result video (before / after)

    Android: Native
    Before After
    before.mp4
    after.mp4
  10. linhvovan29546 commented on Dec 9, 2024

    @linhvovan29546
    Contributor

    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?

    • The issue originates from this commit in the PR: Migrate E/App to use PlatformStackNavigation.
      • Prior to this change, the problem did not exist.
      • 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:
    • Update the getActionForBottomTabNavigator function
    • Update the navigateWithSwitchPolicyID function in WorkspaceSwitcherPage:
      • Pass shouldReplaceHome: false .
      • This ensures the navigation method is Push instead of Replace when called from this screen.
      • (Optional) Add a condition to ensure this change only applies to Android.
    Results ### Demo Videos
    Before After
    back-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

  11. 45 remaining items

  12. RachCHopkins commented on Dec 31, 2024

    @RachCHopkins
    Contributor

    Contributor to be paid via newdot, there is no contract to complete, and the Upwork post has been closed.

  13. melvin-bot commented on Jan 2, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    • Contributor: @chrispader is from an agency-contributor and not due payment
    • Reviewer: @eh2077 owed $250 via NewDot

    BugZero Checklist (@RachCHopkins)

    • 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/1864885051135538956/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  14. eh2077 commented on Jan 2, 2025

    @eh2077
    Contributor

    BugZero Checklist:

    • [Contributor] Classify the bug:
    Bug classification

    Source of bug:

    • 1a. Result of the original design (eg. a case wasn't considered)
    • 1b. Mistake during implementation
    • 1c. Backend bug
    • 1z. Other:

    Where bug was reported:

    • 2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
    • 2b. Reported on staging (eg. found during regression or PR testing)
    • 2d. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:

    Regression Test Proposal

    Precondition:

    • N/A

    Test:

    Blank HomeScreen fix

    1. Open the app
    2. Go to the WS switcher
    3. Switch to/Filter by a workspace
    4. Make sure that there is no blank screen when navigating back to the HomeScreen.

    App closing when going back after switching workspace

    1. Open the app
    2. Go to the WS switcher
    3. Switch to/Filter by a workspace
    4. Use device back button/gesture
    5. Make sure the app doesn't close but the app navigates to the previous workspace

    Search page briefly goes blank when switching workspace

    1. Open the app
    2. Go to the search tab
    3. Go to the WS switcher
    4. Switch to/Filter by a workspace
    5. Make sure that there is no blank screen when navigating back to the SearchScreen.

    Do we agree 👍 or 👎

  15. melvin-bot commented on Jan 7, 2025

    @melvin-bot

    @chrispader, @RachCHopkins, @mountiny, @eh2077 Eep! 4 days overdue now. Issues have feelings too...

  16. RachCHopkins commented on Jan 8, 2025

    @RachCHopkins
    Contributor

    Sorry team, will get this paid out asap - it was hiding due to a filter at my end!

  17. 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
  18. RachCHopkins commented on Jan 10, 2025

    @RachCHopkins
    Contributor

    Payment Summary:

    Contributor: @chrispader - no payment due (contractor)
    Contributor+: @eh2077 to bepaid $250 via NewDot Manual Request.
    Upwork job here

  19. RachCHopkins commented on Jan 10, 2025

    @RachCHopkins
    Contributor

    Contributor is to be paid via Newdot, there is no contract to complete, and the Upwork post has been closed.

  20. JmillsExpensify commented on Jan 10, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @eh2077

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

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions