diff --git a/src/libs/actions/App.ts b/src/libs/actions/App.ts index f1f46aee0a93e..61ce04655ae5a 100644 --- a/src/libs/actions/App.ts +++ b/src/libs/actions/App.ts @@ -418,6 +418,7 @@ function savePolicyDraftByNewWorkspace(policyID?: string, policyName?: string, p function setUpPoliciesAndNavigate(session: OnyxEntry) { const currentUrl = getCurrentUrl(); if (!session || !currentUrl?.includes('exitTo')) { + endSignOnTransition(); return; } @@ -445,6 +446,8 @@ function setUpPoliciesAndNavigate(session: OnyxEntry) { Navigation.navigate(exitTo); }) .then(endSignOnTransition); + } else { + endSignOnTransition(); } } diff --git a/src/pages/LogOutPreviousUserPage.tsx b/src/pages/LogOutPreviousUserPage.tsx index f37759eeaa88d..3f286a230c440 100644 --- a/src/pages/LogOutPreviousUserPage.tsx +++ b/src/pages/LogOutPreviousUserPage.tsx @@ -70,11 +70,13 @@ function LogOutPreviousUserPage({route}: LogOutPreviousUserPageProps) { // because we already handle creating the optimistic policy and navigating to it in App.setUpPoliciesAndNavigate, // which is already called when AuthScreens mounts. // For HybridApp we have separate logic to handle transitions. - if (!NativeModules.HybridAppModule && exitTo && exitTo !== ROUTES.WORKSPACE_NEW && !isAccountLoading && !isLoggingInAsNewUser) { + if (!NativeModules.HybridAppModule && exitTo !== ROUTES.WORKSPACE_NEW && !isAccountLoading && !isLoggingInAsNewUser) { Navigation.isNavigationReady().then(() => { // remove this screen and navigate to exit route Navigation.goBack(); - Navigation.navigate(exitTo); + if (exitTo) { + Navigation.navigate(exitTo); + } }); } // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps