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

[$500] Infinite loading when accessing a non-existing workspace #36442

Closed
1 of 6 tasks
m-natarajan opened this issue Feb 13, 2024 · 20 comments
Closed
1 of 6 tasks

[$500] Infinite loading when accessing a non-existing workspace #36442

m-natarajan opened this issue Feb 13, 2024 · 20 comments
Assignees
Labels
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

@m-natarajan
Copy link

m-natarajan commented Feb 13, 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: 1.4.41-2
Reproducible in staging?: y
Reproducible in production?: y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @hayata-suenaga
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1707848696684749

Action Performed:

  1. Log out
  2. Go to some WS link, e.g. https://staging.new.expensify.com/workspace/adsasddssad/rateandunit (doesn't matter if policy exist or not)
  3. Log in

Expected Result:

Shouldn't be infinite loading

Actual Result:

Infinite loading appears

Workaround:

unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence
Screen Shot 2024-02-13 at 5 07 35 PM

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~019c756122ca1f4027
  • Upwork Job ID: 1757527427083399168
  • Last Price Increase: 2024-02-13
  • Automatic offers:
    • fedirjh | Reviewer | 0
    • bernhardoj | Contributor | 0
Issue OwnerCurrent Issue Owner: @fedirjh
@m-natarajan m-natarajan added External Added to denote the issue can be worked on by a contributor Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Feb 13, 2024
@melvin-bot melvin-bot bot changed the title Infinite loading when accessing a non-existing workspace [$500] Infinite loading when accessing a non-existing workspace Feb 13, 2024
Copy link

melvin-bot bot commented Feb 13, 2024

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 13, 2024
Copy link

melvin-bot bot commented Feb 13, 2024

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

Copy link

melvin-bot bot commented Feb 13, 2024

Triggered auto assignment to @slafortune (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details.

@abzokhattab
Copy link
Contributor

the issue is not reproducible on the latest main.

@kosmydel
Copy link
Contributor

the issue is not reproducible on the latest main.

I can still reproduce it.

@hayata-suenaga
Copy link
Contributor

I can also still reproduce this

@bernhardoj
Copy link
Contributor

Proposal

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

If we open a nonexistent workspace page after login, the app will load indefinitely.

What is the root cause of that problem?

When we open a nonexistent workspace page after login, the OpenApp request is never called. It will only be called if isReadyToOpenApp promise is resolved.

isReadyToOpenApp.then(() => {

App.confirmReadyToOpenApp is used to resolve the promise and it currently is called in both ReportScreenIDSetter and SidebarLinks. When we open the workspace page after login, the report screen isn't added to the navigation stack, so App.confirmReadyToOpenApp is never called in ReportScreenIDSetter.

In SidebarLinks, App.confirmReadyToOpenApp is called only on small screen.

useEffect(() => {
if (!isSmallScreenWidth) {
return;
}
App.confirmReadyToOpenApp();
}, [isSmallScreenWidth]);

Because the promise isn't resolved, the app shows the loading indicator infinitely.

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

SidebarLinks is placed inside the bottom tab navigator which is always exist in the nav stack, so I think we can just have one place to call App.confirmReadyToOpenApp inside SidebarLinks. So, we can just remove the small screen condition.

useEffect(() => {
if (!isSmallScreenWidth) {
return;
}
App.confirmReadyToOpenApp();
}, [isSmallScreenWidth]);

@fedirjh
Copy link
Contributor

fedirjh commented Feb 14, 2024

When we open the workspace page after login, the report screen isn't added to the navigation stack, so App.confirmReadyToOpenApp is never called in ReportScreenIDSetter.

@bernhardoj Your proposal makes sense. I am just wondering why ReportScreenIDSetter is never mounted? is it mounted after the reports are loaded? And are the reports loaded after OpenApp is called?

@bernhardoj
Copy link
Contributor

ReportScreenIDSetter will be mounted alongside ReportScreen.

return (
<>
<ReportScreen
// @ts-expect-error Error will be resolved after ReportScreen migration to TypeScript
route={route}
navigation={navigation}
/>
<ReportScreenIDSetter
route={route}
navigation={navigation}
/>
</>
);

If you are aware, before the ideal nav, in CustomRouter, we have a logic to make sure the report screen (specifically CentralPaneNavigator) is always added to the nav stack on large screen. (old code below)

// Make sure that there is at least one CentralPaneNavigator (ReportScreen by default) in the state if this is a wide layout
if (!isAtLeastOneCentralPaneNavigatorInState(partialState) && !options.getIsSmallScreenWidth()) {

CentralPaneNavigator now includes workspace screen (overview, reimburse, etc.).

return (
<Stack.Navigator screenOptions={options}>
<Stack.Screen
name={SCREENS.REPORT}
// We do it this way to avoid adding the url params to url
initialParams={{openOnAdminRoom: openOnAdminRoom === 'true' || undefined}}
component={ReportScreenWrapper}
/>
{Object.entries(workspaceSettingsScreens).map(([screenName, componentGetter]) => (
<Stack.Screen
key={screenName}
name={screenName as keyof Screens}
getComponent={componentGetter}
/>
))}
</Stack.Navigator>
);

The new CustomRouter logic now making sure to add a full screen or central pane navigator to the nav stack

const pathFromCurrentState = getPathFromState(state, linkingConfig.config);
const {adaptedState: templateState} = getAdaptedStateFromPath(pathFromCurrentState, linkingConfig.config);
if (!templateState) {
return;
}
const templateFullScreenRoute = templateState.routes.find((route) => route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR);
// If templateFullScreenRoute is defined, and full screen route is not in the state, we need to add it.
if (templateFullScreenRoute) {
insertRootRoute(state, templateFullScreenRoute);
return;
}
const topmostCentralPaneRoute = state.routes.filter((route) => route.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR).at(-1);
const templateCentralPaneRoute = templateState.routes.find((route) => route.name === NAVIGATORS.CENTRAL_PANE_NAVIGATOR);
const topmostCentralPaneRouteExtracted = getTopmostCentralPaneRoute(state);
const templateCentralPaneRouteExtracted = getTopmostCentralPaneRoute(templateState as State<RootStackParamList>);
// If there is no templateCentralPaneRoute, we don't have anything to add.
if (!templateCentralPaneRoute) {
return;
}
// If there is no topmostCentralPaneRoute in the state and template state has one, we need to add it.
if (!topmostCentralPaneRoute) {
insertRootRoute(state, templateCentralPaneRoute);
return;
}

In this case, visiting /workspace/{policyID}/rateandunit adds WorkspaceReimburse (belongs to CentralPaneNavigator) to the stack

@fedirjh
Copy link
Contributor

fedirjh commented Feb 19, 2024

@bernhardoj's proposal looks good to me. Let's proceed with it.

🎀 👀 🎀 C+ reviewed

Copy link

melvin-bot bot commented Feb 19, 2024

Triggered auto assignment to @blimpich, see https://stackoverflow.com/c/expensify/questions/7972 for more details.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 19, 2024
Copy link

melvin-bot bot commented Feb 19, 2024

📣 @fedirjh 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job

Copy link

melvin-bot bot commented Feb 19, 2024

📣 @bernhardoj 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

@bernhardoj
Copy link
Contributor

PR is ready

cc: @fedirjh

@slafortune
Copy link
Contributor

Looks like the automated system didn't update. Deployed to production on Feb 28 - 7 holding day means payment would be due on March 6th

@fedirjh
Copy link
Contributor

fedirjh commented Mar 15, 2024

@blimpich Could you please remove the Reviewing label and bump to Daily as payment is due? Thanks

@blimpich blimpich added Daily KSv2 and removed Reviewing Has a PR in review Weekly KSv2 labels Mar 15, 2024
@blimpich
Copy link
Contributor

@slafortune can you handle payment here?

@melvin-bot melvin-bot bot added the Overdue label Mar 18, 2024
@slafortune
Copy link
Contributor

slafortune commented Mar 18, 2024

Sorry I lost sight of this one! PAID!

@fedirjh can you please complete the checklist?

BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@fedirjh] The PR that introduced the bug has been identified. Link to the PR:
  • [@fedirjh] 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:
  • [@fedirjh] A discussion in #expensify-bugs 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:
  • [@fedirjh] Determine if we should create a regression test for this bug.
  • [@fedirjh] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
  • [@slafortune] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:

@melvin-bot melvin-bot bot removed the Overdue label Mar 18, 2024
@fedirjh fedirjh mentioned this issue Mar 19, 2024
50 tasks
@fedirjh
Copy link
Contributor

fedirjh commented Mar 19, 2024

BugZero Checklist:

Regression Test Proposal

1. Log out
2. Go to some WS link, e.g. https://staging.new.expensify.com/workspace/adsasddssad/rateandunit (doesn't matter if policy exist or not)
3. Log in
4. Verify the loading indicator is shown. Wait for a few seconds for the app to load
5. Verify the app loads complete and a not found page or workspace page is shown
  • Do we agree 👍 or 👎

@melvin-bot melvin-bot bot added the Overdue label Mar 22, 2024
@slafortune
Copy link
Contributor

Thanks @fedirjh !

@melvin-bot melvin-bot bot removed the Overdue label Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
No open projects
Status: CRITICAL
Development

No branches or pull requests

8 participants