Skip to content

Commit dfbbfcc

Browse files
authored
Merge pull request Expensify#66066 from mkzie2/mkzie2-issue/65949
fix user is logged out when going from OD
2 parents 4a14376 + fa5393a commit dfbbfcc

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/hooks/useOnboardingFlow.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import {useEffect, useRef} from 'react';
22
import {InteractionManager} from 'react-native';
33
import {startOnboardingFlow} from '@libs/actions/Welcome/OnboardingFlow';
4+
import getCurrentUrl from '@libs/Navigation/currentUrl';
45
import Navigation from '@libs/Navigation/Navigation';
56
import {hasCompletedGuidedSetupFlowSelector, tryNewDotOnyxSelector} from '@libs/onboardingSelectors';
67
import {buildCannedSearchQuery} from '@libs/SearchQueryUtils';
8+
import {isLoggingInAsNewUser} from '@libs/SessionUtils';
79
import isProductTrainingElementDismissed from '@libs/TooltipUtils';
810
import CONFIG from '@src/CONFIG';
911
import ONYXKEYS from '@src/ONYXKEYS';
@@ -17,12 +19,15 @@ import useOnyx from './useOnyx';
1719
* Warning: This hook should be used only once in the app
1820
*/
1921
function useOnboardingFlowRouter() {
22+
const currentUrl = getCurrentUrl();
2023
const [isLoadingApp = true] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true});
2124
const [onboardingValues, isOnboardingCompletedMetadata] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
2225
canBeMissing: true,
2326
});
2427

2528
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
29+
const [sessionEmail] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: true, selector: (session) => session?.email});
30+
const isLoggingInAsNewSessionUser = isLoggingInAsNewUser(currentUrl, sessionEmail);
2631
const startedOnboardingFlowRef = useRef(false);
2732
const [tryNewDot, tryNewDotMetadata] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {
2833
selector: tryNewDotOnyxSelector,
@@ -37,6 +42,10 @@ function useOnboardingFlowRouter() {
3742
useEffect(() => {
3843
// This should delay opening the onboarding modal so it does not interfere with the ongoing ReportScreen params changes
3944
InteractionManager.runAfterInteractions(() => {
45+
// Prevent starting the onboarding flow if we are logging in as a new user with short lived token
46+
if (currentUrl?.includes(ROUTES.TRANSITION_BETWEEN_APPS) && isLoggingInAsNewSessionUser) {
47+
return;
48+
}
4049
if (isLoadingApp !== false) {
4150
return;
4251
}
@@ -109,6 +118,8 @@ function useOnboardingFlowRouter() {
109118
dismissedProductTraining,
110119
account?.isFromPublicDomain,
111120
account?.hasAccessibleDomainPolicies,
121+
currentUrl,
122+
isLoggingInAsNewSessionUser,
112123
]);
113124

114125
return {isOnboardingCompleted: hasCompletedGuidedSetupFlowSelector(onboardingValues), isHybridAppOnboardingCompleted};

src/libs/actions/Report.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,6 +3390,11 @@ function openReportFromDeepLink(url: string) {
33903390
return;
33913391
}
33923392

3393+
// If the route is the transition route, we don't want to navigate and start the onboarding flow
3394+
if (route?.includes(ROUTES.TRANSITION_BETWEEN_APPS)) {
3395+
return;
3396+
}
3397+
33933398
// Navigate to the report after sign-in/sign-up.
33943399
InteractionManager.runAfterInteractions(() => {
33953400
waitForUserSignIn().then(() => {

0 commit comments

Comments
 (0)