diff --git a/src/libs/actions/App.ts b/src/libs/actions/App.ts index 3a2241bd5494..768dc530cc51 100644 --- a/src/libs/actions/App.ts +++ b/src/libs/actions/App.ts @@ -398,7 +398,7 @@ function setUpPoliciesAndNavigate(session: OnyxEntry) { return; } if (!isLoggingInAsNewUser && exitTo) { - Navigation.isNavigationReady() + Navigation.waitForProtectedRoutes() .then(() => { // We must call goBack() to remove the /transition route from history Navigation.goBack(ROUTES.HOME); diff --git a/src/pages/LogOutPreviousUserPage.js b/src/pages/LogOutPreviousUserPage.js index 9609f3f9bd56..5c8a39204467 100644 --- a/src/pages/LogOutPreviousUserPage.js +++ b/src/pages/LogOutPreviousUserPage.js @@ -5,10 +5,8 @@ import {Linking} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import * as SessionUtils from '@libs/SessionUtils'; -import Navigation from '@navigation/Navigation'; import * as Session from '@userActions/Session'; import ONYXKEYS from '@src/ONYXKEYS'; -import ROUTES from '@src/ROUTES'; const propTypes = { /** The details about the account that the user is signing in with */ @@ -33,6 +31,10 @@ const defaultProps = { }, }; +// This page is responsible for handling transitions from OldDot. Specifically, it logs the current user +// out if the transition is for another user. +// +// This component should not do any other navigation as that handled in App.setUpPoliciesAndNavigate function LogOutPreviousUserPage(props) { useEffect(() => { Linking.getInitialURL().then((transitionURL) => { @@ -53,18 +55,11 @@ function LogOutPreviousUserPage(props) { const shortLivedAuthToken = lodashGet(props, 'route.params.shortLivedAuthToken', ''); Session.signInWithShortLivedAuthToken(email, shortLivedAuthToken); } - - const exitTo = lodashGet(props, 'route.params.exitTo', ''); - // We don't want to navigate to the exitTo route when creating a new workspace from a deep link, - // because we already handle creating the optimistic policy and navigating to it in App.setUpPoliciesAndNavigate, - // which is already called when AuthScreens mounts. - if (exitTo && exitTo !== ROUTES.WORKSPACE_NEW && !props.account.isLoading && !isLoggingInAsNewUser) { - Navigation.isNavigationReady().then(() => { - Navigation.navigate(exitTo); - }); - } }); - }, [props]); + + // We only want to run this effect once on mount (when the page first loads after transitioning from OldDot) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); return ; }