Skip to content

[HOLD for payment 2025-02-04] [$250] Android - Previously selected workspace is shown briefly while navigating via workspace switcher #54554

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.78-2
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes
Issue reported by: Applause Internal Team
Device used: Redmi note 10s Android 13
App Component: Left Hand Navigation (LHN)

Action Performed:

  1. Launch app
  2. Login with account having many workspaces
  3. Tap expensify switcher
  4. Select a workspace
  5. Note home page is shown briefly before showing the selected workspace page
  6. Repeat the step 4 few times
  7. Note everytime previously selected workspace is shown briefly before showing selected workspace page.

Expected Result:

Previously selected workspace must not be shown briefly before showing the selected workspace page while navigating to workspace using workspace switcher.

Actual Result:

Previously selected workspace is shown briefly before showing the selected workspace page while navigating to workspace using workspace switcher.

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6701969_1735093987379.Screenrecorder-2024-12-25-07-51-32-944_compress_1.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021874207316888194452
  • Upwork Job ID: 1874207316888194452
  • Last Price Increase: 2025-01-14
Issue OwnerCurrent Issue Owner: @anmurali

Activity

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

    @melvin-bot

    Triggered auto assignment to @anmurali (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. bernhardoj commented on Dec 26, 2024

    @bernhardoj
    Contributor

    Proposal

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

    The selected workspace LHN is shown then the previous workspace and then the selected workspace again when switching workspace.

    What is the root cause of that problem?

    When we select a workspace, we update the active workspace context to the selected workspace.

    setActiveWorkspaceID(newPolicyID);
    Navigation.goBack();
    if (newPolicyID !== activeWorkspaceID) {
    // On native platforms, we will see a blank screen if we navigate to a new HomeScreen route while navigating back at the same time.
    // Therefore we delay switching the workspace until after back navigation, using the InteractionManager.
    switchPolicyAfterInteractions(newPolicyID);
    }
    },

    This will update the LHN immediately to show the selected workspace report list. However, the switchPolicyID which updates the route is delayed on native intentionally in #54030. That's why the top bar isn't updated yet because it depends on the nav route.

    const activeWorkspaceID = useActiveWorkspaceFromNavigationState();
    const {translate} = useLocalize();
    const {shouldUseNarrowLayout} = useResponsiveLayout();
    const [activeWorkspace] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activeWorkspaceID ?? CONST.DEFAULT_NUMBER_ID}`);

    And because we close the switcher page, the nav state is changed and the active workspace is updated based on the current nav state, which the results will be the previous workspace, so the LHN now shows the previous workspace LHN.

    const activeWorkspaceID = getPolicyIDFromState(state as NavigationState<RootStackParamList>);
    // Performance optimization to avoid context consumers to delay first render
    setTimeout(() => {
    currentReportIDValue?.updateCurrentReportID(state);
    setActiveWorkspaceID(activeWorkspaceID);
    }, 0);

    After the switchPolicyID delay is done, the active workspace is set to the selected workspace, and the LHN is now updated to the selected workspace (and the top bar).

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

    We have 2 options. First, we need to put the setActiveWorkspace inside the InteractionManager too (for native).

    Second, we can remove setActiveWorkspace because it'll be updated when the state is changed by switchPolicyID, but it's probably expected to call setActiveWorkspace separately so it's updated faster without waiting for the nav state update logic.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    I think we can mock the interaction manager and when selecting a workspace, we need to assert that the LHN list isn't updated before we resolve the mocked interaction manager.

  4. daledah commented on Dec 26, 2024

    @daledah
    Contributor

    Proposal

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

    Previously selected workspace is shown briefly before showing the selected workspace page while navigating to workspace using workspace switcher.

    What is the root cause of that problem?

    Let's assume we're in WS A

    1. When switching WS to WS B, activeWorkspaceID is set to B

    setActiveWorkspaceID(newPolicyID);

    1. then perform goBack

    InteractionManager.runAfterInteractions(() => {
    Navigation.navigateWithSwitchPolicyID({policyID: newPolicyID});
    });

    The active WS ID at that time is still in the stack, so it's A -> activeWorkspaceID is set to A

    1. then navigate to new WS

    Navigation.goBack();
    if (newPolicyID !== activeWorkspaceID) {
    // On native platforms, we will see a blank screen if we navigate to a new HomeScreen route while navigating back at the same time.
    // Therefore we delay switching the workspace until after back navigation, using the InteractionManager.
    switchPolicyAfterInteractions(newPolicyID);

    activeWorkspaceID is set to B

    That's why we can see the blink issue

    Note: This issue doesn't happen on web since we're delayed switchPolicyAfterInteractions on native device only. On web, 2 actions perform at the same time so handleStateChange is triggered with up-to-date state

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

    We should move the logic goBack to web only here

    I tested this issue and tried to go back after switching to new WS on all platforms and they worked well.

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    What alternative solutions did you explore? (Optional)

    We can remove this condition:

    if (newPolicyID !== activeWorkspaceID) {

    since newPolicyID is always different from activeWorkspaceID

    const newPolicyID = policyID === activeWorkspaceID ? undefined : policyID;

    Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job.

  5. daledah commented on Dec 26, 2024

    @daledah
    Contributor

    Note for C+: If we put the setActiveWorkspace inside the InteractionManager, we can still see the blink issue

  6. melvin-bot commented on Dec 31, 2024

    @melvin-bot

    @anmurali Huh... This is 4 days overdue. Who can take care of this?

  7. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Dec 31, 2024
  8. melvin-bot commented on Dec 31, 2024

    @melvin-bot
  9. changed the title [-]Android - Previously selected workspace is shown briefly while navigating via workspace switcher[/-] [+][$250] Android - Previously selected workspace is shown briefly while navigating via workspace switcher[/+] on Dec 31, 2024
  10. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Dec 31, 2024
  11. melvin-bot commented on Dec 31, 2024

    @melvin-bot

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

  12. 40 remaining items

  13. rayane-d commented on Feb 3, 2025

    @rayane-d
    Contributor

    BugZero Checklist:

    • 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
    • 2b. Reported on staging (deploy blocker)
    • 2c. Reported on a PR
    • 2z. Other:

    Who reported the bug:

    • 3a. Expensify user
    • 3b. Expensify employee
    • 3c. Contributor
    • 3d. QA
    • 3z. Other:
    • 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/54030/files#r1939592503

    • 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

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

    • [@anmurali] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue:

    Regression Test Proposal

    
    #### Test:
    
    1. Log in with an account that has multiple workspaces.
    2. Open the workspace switcher.
    3. Select workspace (A).
    4. Open the workspace switcher again.
    5. Select workspace (B).
    6. Verify that there is no brief transition like this: workspace (B) chats > workspace (A) chats > workspace (B) chats.
    7. Verify that the chats on the home page change from workspace (A) chats to workspace (B) chats (workspace (A) chats > workspace (B)).
    
    

    Do we agree 👍 or 👎

  14. melvin-bot commented on Feb 3, 2025

    @melvin-bot

    📣 @rayane-d! 📣
    Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
    Please follow these steps:

    1. Make sure you've read and understood the contributing guidelines.
    2. Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
    3. Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
    4. Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
      Screen Shot 2022-11-16 at 4 42 54 PM
      Format:
    Contributor details
    Your Expensify account email: <REPLACE EMAIL HERE>
    Upwork Profile Link: <REPLACE LINK HERE>
    
  15. melvin-bot commented on Feb 4, 2025

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@anmurali)

    • 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/1874207316888194452/hired)
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  16. rayane-d commented on Feb 4, 2025

    @rayane-d
    Contributor

    Requested in NewDot

  17. bernhardoj commented on Feb 4, 2025

    @bernhardoj
    Contributor

    Requested in ND.

  18. anmurali commented on Feb 5, 2025

    @anmurali

    Payment Summary

  19. melvin-bot commented on Feb 10, 2025

    @melvin-bot

    @anmurali, @srikarparsi, @bernhardoj, @rayane-d Huh... This is 4 days overdue. Who can take care of this?

  20. JmillsExpensify commented on Feb 10, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @bernhardoj

  21. garrettmknight commented on Feb 11, 2025

    @garrettmknight
    Contributor

    $250 approved for @rayane-d

  22. melvin-bot commented on Feb 12, 2025

    @melvin-bot

    @anmurali, @srikarparsi, @bernhardoj, @rayane-d 6 days overdue. This is scarier than being forced to listen to Vogon poetry!

  23. mallenexpensify commented on Feb 14, 2025

    @mallenexpensify
    Contributor

    Everyone is paid, test case below, thx, closing

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

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions