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

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

Closed
2 of 8 tasks
IuliiaHerets opened this issue Dec 25, 2024 · 39 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor

Comments

@IuliiaHerets
Copy link

IuliiaHerets commented Dec 25, 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.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
@IuliiaHerets IuliiaHerets added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Dec 25, 2024
Copy link

melvin-bot bot commented Dec 25, 2024

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.

@bernhardoj
Copy link
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.

@daledah
Copy link
Contributor

daledah commented Dec 26, 2024

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.

@daledah
Copy link
Contributor

daledah commented Dec 26, 2024

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

@melvin-bot melvin-bot bot added the Overdue label Dec 27, 2024
Copy link

melvin-bot bot commented Dec 31, 2024

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

@anmurali anmurali added the External Added to denote the issue can be worked on by a contributor label Dec 31, 2024
Copy link

melvin-bot bot commented Dec 31, 2024

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

@melvin-bot melvin-bot bot 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 Dec 31, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Dec 31, 2024
Copy link

melvin-bot bot commented Dec 31, 2024

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

@melvin-bot melvin-bot bot removed the Overdue label Dec 31, 2024
Copy link

melvin-bot bot commented Jan 6, 2025

@anmurali, @rayane-djouah Eep! 4 days overdue now. Issues have feelings too...

@melvin-bot melvin-bot bot added the Overdue label Jan 6, 2025
@daledah
Copy link
Contributor

daledah commented Jan 7, 2025

@rayane-djouah What do you think about my proposal? Thanks

Copy link

melvin-bot bot commented Jan 7, 2025

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

@rayane-d
Copy link
Contributor

rayane-d commented Jan 8, 2025

@daledah I've found a bug with your suggested solution - when you select a workspace from the list, the list order change (the selected workspace move to the top) before navigating back

@melvin-bot melvin-bot bot removed the Overdue label Jan 8, 2025
Copy link

melvin-bot bot commented Jan 8, 2025

@anmurali @rayane-djouah 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!

@daledah
Copy link
Contributor

daledah commented Jan 8, 2025

@rayane-djouah Can you please share the video/screenshot? I can't reproduce your bug.

@rayane-d
Copy link
Contributor

@daledah Here are videos:

Screen.Recording.2025-01-13.at.3.59.34.AM.mov
Screen.Recording.2025-01-13.at.3.28.14.AM.mov

You can notice that the selected workspace moves to the top of the list before navigating. Maybe it is expected?

@rayane-d
Copy link
Contributor

@bernhardoj I tested your solution, but I'm still able to reproduce the blinking bug.

@bernhardoj
Copy link
Contributor

@rayane-djouah may I know how you implement it? This is how I implement the 1st solution:

diff

this just covers the native changes.

diff --git a/src/pages/WorkspaceSwitcherPage/index.tsx b/src/pages/WorkspaceSwitcherPage/index.tsx
index 4f2d0768976..f18856082ea 100644
--- a/src/pages/WorkspaceSwitcherPage/index.tsx
+++ b/src/pages/WorkspaceSwitcherPage/index.tsx
@@ -89,12 +89,11 @@ function WorkspaceSwitcherPage() {
             }
             const newPolicyID = policyID === activeWorkspaceID ? undefined : policyID;
 
-            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);
+                switchPolicyAfterInteractions(newPolicyID, setActiveWorkspaceID);
             }
         },
         [activeWorkspaceID, setActiveWorkspaceID, isFocused],
diff --git a/src/pages/WorkspaceSwitcherPage/switchPolicyAfterInteractions/index.native.tsx b/src/pages/WorkspaceSwitcherPage/switchPolicyAfterInteractions/index.native.tsx
index a3df127564b..f8ca81440e4 100644
--- a/src/pages/WorkspaceSwitcherPage/switchPolicyAfterInteractions/index.native.tsx
+++ b/src/pages/WorkspaceSwitcherPage/switchPolicyAfterInteractions/index.native.tsx
@@ -1,8 +1,9 @@
 import {InteractionManager} from 'react-native';
 import Navigation from '@libs/Navigation/Navigation';
 
-function switchPolicyAfterInteractions(newPolicyID: string | undefined) {
+function switchPolicyAfterInteractions(newPolicyID: string | undefined, setActiveWorkspaceID: (policyID: string | undefined) => void) {
     InteractionManager.runAfterInteractions(() => {
+        setActiveWorkspaceID(newPolicyID);
         Navigation.navigateWithSwitchPolicyID({policyID: newPolicyID});
     });
 }

and here is how it looks:

a.mp4

Copy link

melvin-bot bot commented Jan 14, 2025

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

@daledah
Copy link
Contributor

daledah commented Jan 15, 2025

You can notice that the selected workspace moves to the top of the list before navigating. Maybe it is expected?

I also think it's expected. If it's an actual issue, it should be out of scope since the target of this issue is focusing on the LHN. What do you think @rayane-djouah ?

@melvin-bot melvin-bot bot added the Overdue label Jan 15, 2025
@melvin-bot melvin-bot bot added Weekly KSv2 and removed Daily KSv2 labels Jan 18, 2025
@bernhardoj
Copy link
Contributor

PR is ready

cc: @rayane-djouah

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jan 28, 2025
@melvin-bot melvin-bot bot changed the title [$250] Android - Previously selected workspace is shown briefly while navigating via workspace switcher [HOLD for payment 2025-02-04] [$250] Android - Previously selected workspace is shown briefly while navigating via workspace switcher Jan 28, 2025
@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jan 28, 2025
Copy link

melvin-bot bot commented Jan 28, 2025

Reviewing label has been removed, please complete the "BugZero Checklist".

Copy link

melvin-bot bot commented Jan 28, 2025

The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.89-8 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 2025-02-04. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jan 28, 2025

@rayane-djouah @anmurali @rayane-djouah 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]

@rayane-d
Copy link
Contributor

rayane-d commented Feb 3, 2025

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 👎

Copy link

melvin-bot bot commented Feb 3, 2025

📣 @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>

Copy link

melvin-bot bot commented Feb 4, 2025

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

@rayane-d
Copy link
Contributor

rayane-d commented Feb 4, 2025

Requested in NewDot

@bernhardoj
Copy link
Contributor

Requested in ND.

@anmurali
Copy link

anmurali commented Feb 5, 2025

Payment Summary

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Feb 5, 2025
Copy link

melvin-bot bot commented Feb 10, 2025

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

@JmillsExpensify
Copy link

$250 approved for @bernhardoj

@garrettmknight
Copy link
Contributor

$250 approved for @rayane-d

Copy link

melvin-bot bot commented Feb 12, 2025

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

@mallenexpensify
Copy link
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
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 External Added to denote the issue can be worked on by a contributor
Projects
None yet
Development

No branches or pull requests

10 participants