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

[$250] Android - Secondary Log in - An endless spinner when trying validate the secondary login #11964

Closed
kavimuru opened this issue Oct 18, 2022 · 24 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Improvement Item broken or needs improvement.

Comments

@kavimuru
Copy link

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Action Performed:

  1. Log in to NewDot with any account
  2. Log into OldDot with the same account and add a Secondary Login from Account Settings
  3. Open validate secondary log in email Verify secondary email for Expensify and copy the last part of the URL, i.e. /v/16/WSSWMNNM (Everything after the /v/)
  4. In a text box - Formulate the URL by using the path obtained from step 3 http://staging.new.expensify.com/v/
  5. Navigate to the compiled link

Expected Result:

You should redirected to LHN with no error message displayed

Actual Result:

An endless spinner when trying validate the secondary login

Workaround:

unknown

Platform:

Where is this issue occurring?

  • Android

Version Number: v1.2.17-4
Reproducible in staging?: y
Reproducible in production?: y
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Notes/Photos/Videos:

Bug5782073_video_2022-10-18_18-31-21.mp4

Expensify/Expensify Issue URL:
Issue reported by: Applause internal team
Slack conversation:

View all open jobs on GitHub

@neil-marcellini
Copy link
Contributor

Weird, where did we get these reproduction steps from? Do we support validating a secondary login on NewDot?

@puneetlath puneetlath added the Bug Something is broken. Auto assigns a BugZero manager. label Oct 19, 2022
@kavimuru
Copy link
Author

@melvin-bot melvin-bot bot added the Overdue label Oct 20, 2022
@neil-marcellini
Copy link
Contributor

Okay got it thanks for clarifying. I'm able to reproduce the issue. I'm also able to reproduce the issue on iOS. I can't reproduce on Web so maybe it has something to do with the small screen width? I'll send it external because if it's limited to certain platforms then it's probably a front end issue.

Screen.Recording.2022-10-20.at.4.54.21.PM.mov

@melvin-bot melvin-bot bot removed the Overdue label Oct 21, 2022
@neil-marcellini neil-marcellini removed their assignment Oct 21, 2022
@neil-marcellini neil-marcellini added Improvement Item broken or needs improvement. External Added to denote the issue can be worked on by a contributor labels Oct 21, 2022
@melvin-bot
Copy link

melvin-bot bot commented Oct 21, 2022

Triggered auto assignment to @davidcardoza (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

@melvin-bot
Copy link

melvin-bot bot commented Oct 21, 2022

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Oct 21, 2022
@melvin-bot
Copy link

melvin-bot bot commented Oct 21, 2022

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

@melvin-bot melvin-bot bot changed the title Android - Secondary Log in - An endless spinner when trying validate the secondary login [$250] Android - Secondary Log in - An endless spinner when trying validate the secondary login Oct 21, 2022
@davidcardoza
Copy link
Contributor

I can't reproduce the issue on iOS or web. This error seems to be isolated to Android only.

@melvin-bot melvin-bot bot added the Overdue label Oct 26, 2022
@tgolen
Copy link
Contributor

tgolen commented Oct 26, 2022

Waitng for proposals

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Oct 26, 2022
@wildan-m
Copy link
Contributor

Proposal

Root cause:

<FullScreenLoadingIndicator /> is not dismissed before calling Navigation.navigate(ROUTES.HOME); in validateLogin

Solution

Adding Navigation.goBack(); before navigating to home will resolve the issue.

diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js
index c1f11e3610..8d549fb099 100644
--- a/src/libs/actions/User.js
+++ b/src/libs/actions/User.js
@@ -220,6 +220,7 @@ function validateLogin(accountID, validateCode) {
         accountID,
         validateCode,
     }, {optimisticData});
+    Navigation.goBack();
     Navigation.navigate(ROUTES.HOME);
 }

Another solution is also to pop the navigation when the user logged in or logged out:

diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js
index e937e50159..9bfd819e12 100644
--- a/src/libs/Navigation/Navigation.js
+++ b/src/libs/Navigation/Navigation.js
@@ -64,7 +64,6 @@ function openDrawer() {
     if (!canNavigate('openDrawer')) {
         return;
     }
-
     navigationRef.current.dispatch(DrawerActions.openDrawer());
     Keyboard.dismiss();
 }
@@ -140,15 +139,14 @@ function navigate(route = ROUTES.HOME) {
     }
 
     if (route === ROUTES.HOME) {
+        // If we're navigating to the signIn page, pop whatever screen is on top
+        // since it's guaranteed that the sign in page will be underneath (since it's the initial route).
+        // Also, if we're coming from a link to validate login (pendingRoute is not null), we want to pop the loading screen.
+        navigationRef.current.dispatch(StackActions.pop());
         if (isLoggedIn && pendingRoute === null) {
             openDrawer();
             return;
         }
-
-        // If we're navigating to the signIn page while logged out, pop whatever screen is on top
-        // since it's guaranteed that the sign in page will be underneath (since it's the initial route).
-        // Also, if we're coming from a link to validate login (pendingRoute is not null), we want to pop the loading screen.
-        navigationRef.current.dispatch(StackActions.pop());
         return;
     }

The second solution might affect another part since Navigation.navigate(ROUTES.HOME) is used in multiple places.

@melvin-bot
Copy link

melvin-bot bot commented Oct 29, 2022

Looks like something related to react-navigation may have been mentioned in this issue discussion.

As a reminder, please make sure that all proposals are not workarounds and that any and all attempt to fix the issue holistically have been made before proceeding with a solution. Proposals to change our DeprecatedCustomActions.js files should not be accepted.

Feel free to drop a note in #expensify-open-source with any questions.

@eVoloshchak
Copy link
Contributor

@wildan-m, thanks for your proposal!

Moving navigationRef.current.dispatch(StackActions.pop()); would result in it being called every time user is navigating back to root.

Calling Navigation.goBack() in validateLogin would actually work. But this feels like a workaround.

The proposal should answer the question of why is this happening?
Why ValidateLoginPage is displayed on top, even when navigating away from it?

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Oct 31, 2022
@tgolen
Copy link
Contributor

tgolen commented Nov 3, 2022

Still working on proposals above. Bump @wildan-m for the questions in the previous comment.

@melvin-bot melvin-bot bot removed the Overdue label Nov 3, 2022
@wildan-m
Copy link
Contributor

wildan-m commented Nov 4, 2022

Proposal (Updated)

Root Cause

ValidateLoginPage and MainDrawer is <RootStack.Navigator> screen and Navigation.navigate(ROUTES.HOME) is directly open the drawer when the user is logged in:

if (route === ROUTES.HOME) {
if (isLoggedIn && pendingRoute === null) {
openDrawer();
return;
}

I think we can't directly trigger openDrawer when the parent navigator is a Stack navigator

I've tried it here:
https://snack.expo.dev/@muhliswildan/nesting-navigators-%7C-react-navigation

Solution

We can replace the dispatch with navigationRef.current.dispatch(StackActions.replace(SCREENS.HOME)) if it comes from ValidateLogin page.

git diff src/libs/Navigation/Navigation.js
diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js
index e937e50159..dbe4665bda 100644
--- a/src/libs/Navigation/Navigation.js
+++ b/src/libs/Navigation/Navigation.js
@@ -6,6 +6,7 @@ import Onyx from 'react-native-onyx';
 import Log from '../Log';
 import linkTo from './linkTo';
 import ROUTES from '../../ROUTES';
+import SCREENS from '../../SCREENS';
 import DeprecatedCustomActions from './DeprecatedCustomActions';
 import ONYXKEYS from '../../ONYXKEYS';
 import linkingConfig from './linkingConfig';
@@ -141,6 +142,11 @@ function navigate(route = ROUTES.HOME) {
 
     if (route === ROUTES.HOME) {
         if (isLoggedIn && pendingRoute === null) {
+            if(navigationRef.current?.getCurrentRoute()?.name === "ValidateLogin")
+            {
+                navigationRef.current.dispatch(StackActions.replace(SCREENS.HOME));
+                return;
+            }
             openDrawer();
             return;
         }

cc: @eVoloshchak @tgolen

@melvin-bot melvin-bot bot added the Overdue label Nov 7, 2022
@melvin-bot
Copy link

melvin-bot bot commented Nov 7, 2022

@tgolen, @davidcardoza, @eVoloshchak Whoops! This issue is 2 days overdue. Let's get this updated quick!

@tgolen
Copy link
Contributor

tgolen commented Nov 7, 2022

Thanks for the updated proposal.

ValidateLoginPage and MainDrawer is <RootStack.Navigator> screen and Navigation.navigate(ROUTES.HOME) is directly open the drawer when the user is logged in:

Sorry, I'm not really following this. It kind of looks like words are missing or the grammar is wrong enough that I'm not understanding the reason. Can you try to reword this, please?

I think we can't directly trigger openDrawer when the parent navigator is a Stack navigator

This sounds like a good guess, but let's make sure that's the problem. Also, if this is indeed the root cause of the problem, can the fix be something that looks at the parent navigator to see if it's a stack navigator or not? I don't like how the proposal only references the ValidateLogin route, since it sounds like it could apply to any route where the parent navigator is a stack navigator.

@melvin-bot melvin-bot bot removed the Overdue label Nov 7, 2022
@wildan-m
Copy link
Contributor

wildan-m commented Nov 7, 2022

Proposal (Updated)

@tgolen

Sorry, I'm not really following this. It kind of looks like words are missing or the grammar is wrong enough that I'm not understanding the reason. Can you try to reword this, please?

Please have a look at this hierarchy

<RootStack.Navigator
mode="modal"
// We are disabling the default keyboard handling here since the automatic behavior is to close a
// keyboard that's open when swiping to dismiss a modal. In those cases, pressing the back button on
// a header will briefly open and close the keyboard and crash Android.
// eslint-disable-next-line react/jsx-props-no-multi-spaces
keyboardHandlingEnabled={false}
>
{/* The MainDrawerNavigator contains the SidebarScreen and ReportScreen */}
<RootStack.Screen
name={SCREENS.HOME}
options={{
headerShown: false,
title: 'New Expensify',
// prevent unnecessary scrolling
cardStyle: {
overflow: 'hidden',
height: '100%',
},
}}
getComponent={() => {
const MainDrawerNavigator = require('./MainDrawerNavigator').default;
return MainDrawerNavigator;
}}
/>
<RootStack.Screen
name="ValidateLogin"
options={{
headerShown: false,
title: 'New Expensify',
}}
getComponent={() => {
const ValidateLoginPage = require('../../../pages/ValidateLoginPage').default;
return ValidateLoginPage;
}}
/>

MainDrawer and ValidateLogin are RootStack navigator screens.

ValidatLoginPage will call this function

User.validateLogin(accountID, validateCode);

which will dispatch the screen with the home screen:

Navigation.navigate(ROUTES.HOME);

But this navigate function directly opens the drawer

if (route === ROUTES.HOME) {
if (isLoggedIn && pendingRoute === null) {
openDrawer();
return;
}

Since ValidateLoginPage is a stack navigator screen and MainDrawer is a child of StackNavigator, openDrawer will not work. The MainDrawer is not loaded/stacked yet.

can the fix be something that looks at the parent navigator to see if it's a stack navigator or not?

I've tweaked the code to include all of the root routes. Please have a look:

git diff src/libs/Navigation/Navigation.js
diff --git a/src/libs/Navigation/Navigation.js b/src/libs/Navigation/Navigation.js
index e937e50159..06e71d173c 100644
--- a/src/libs/Navigation/Navigation.js
+++ b/src/libs/Navigation/Navigation.js
@@ -6,6 +6,7 @@ import Onyx from 'react-native-onyx';
 import Log from '../Log';
 import linkTo from './linkTo';
 import ROUTES from '../../ROUTES';
+import SCREENS from '../../SCREENS';
 import DeprecatedCustomActions from './DeprecatedCustomActions';
 import ONYXKEYS from '../../ONYXKEYS';
 import linkingConfig from './linkingConfig';
@@ -141,6 +142,13 @@ function navigate(route = ROUTES.HOME) {
 
     if (route === ROUTES.HOME) {
         if (isLoggedIn && pendingRoute === null) {
+            const rootRoutes = navigationRef.current.getRootState().routeNames;
+            if(rootRoutes.indexOf(navigationRef.current.getCurrentRoute()?.name) !== -1)
+            {
+                navigationRef.current.dispatch(StackActions.popToTop(SCREENS.HOME));
+                Keyboard.dismiss();
+                return;
+            }
             openDrawer();
             return;
         }

@tgolen
Copy link
Contributor

tgolen commented Nov 8, 2022

Ah, great. Thank you for the more thorough proposal! I think the solution is looking better and I like how it's a bit more generalized now. I was talking with @marcaaron about this issue and he has a lot of knowledge about the navigators, so I think getting his perspective on this proposal would be ideal.

@marcaaron
Copy link
Contributor

Really appreciate the investigation here so far. However, since validating a secondary login has a workaround (can validate via OldDot) and since we are actively discussing deprecating the use of the drawer navigator. I'm not sure we should invest anymore time or energy into short term fixes that are difficult to understand and create a high barrier to entry for our internal engineers and contributors.

@melvin-bot melvin-bot bot added the Overdue label Nov 11, 2022
@eVoloshchak
Copy link
Contributor

Not overdue, the discussion is in progress on whether to use the drawer navigator

@melvin-bot melvin-bot bot added Overdue and removed Overdue labels Nov 11, 2022
@eVoloshchak
Copy link
Contributor

Not overdue

@melvin-bot melvin-bot bot removed the Overdue label Nov 14, 2022
@davidcardoza
Copy link
Contributor

Based on @marcaaron's latest assessment of the issue I think we are good to close this issue. If anyone disagrees please reopen the issue.

@kavimuru
Copy link
Author

kavimuru commented Feb 17, 2023

@davidcardoza Issue is reproducible in Web, mWeb and Desktop as well. Are these navigation issues are on Hold now?

image

Secondary-Login-Endless-Spinner.mp4

@davidcardoza
Copy link
Contributor

I'll lean on @marcaaron's expertise here because I am not sure if we're still actively looking to deprecate the use of the drawer navigator, which would potentially make this not a priority.

@davidcardoza davidcardoza reopened this Feb 18, 2023
@melvin-bot melvin-bot bot added the Overdue label Feb 20, 2023
@tgolen
Copy link
Contributor

tgolen commented Feb 21, 2023

I'm pretty sure our plan is still to deprecate the drawer navigator. This is all being handled in #11768 so I will keep this closed.

@tgolen tgolen closed this as completed Feb 21, 2023
@melvin-bot melvin-bot bot removed the Overdue label Feb 21, 2023
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 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors Improvement Item broken or needs improvement.
Projects
None yet
Development

No branches or pull requests

8 participants