diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.tsx b/src/libs/Navigation/AppNavigator/AuthScreens.tsx index 329941b11d2f..4324116342c7 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.tsx +++ b/src/libs/Navigation/AppNavigator/AuthScreens.tsx @@ -13,6 +13,7 @@ import {useSearchRouterContext} from '@components/Search/SearchRouter/SearchRout import SearchRouterModal from '@components/Search/SearchRouter/SearchRouterModal'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useOnboardingFlowRouter from '@hooks/useOnboardingFlow'; +import usePrevious from '@hooks/usePrevious'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import {SidebarOrderedReportsContextProvider} from '@hooks/useSidebarOrderedReports'; import useTheme from '@hooks/useTheme'; @@ -20,6 +21,7 @@ import {connect} from '@libs/actions/Delegate'; import setFullscreenVisibility from '@libs/actions/setFullscreenVisibility'; import {init, isClientTheLeader} from '@libs/ActiveClientManager'; import {READ_COMMANDS} from '@libs/API/types'; +import getPlatform from '@libs/getPlatform'; import HttpUtils from '@libs/HttpUtils'; import KeyboardShortcut from '@libs/KeyboardShortcut'; import Log from '@libs/Log'; @@ -228,8 +230,11 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie const [account] = useOnyx(ONYXKEYS.ACCOUNT, { canBeMissing: true, }); + const [onboardingCompanySize] = useOnyx(ONYXKEYS.ONBOARDING_COMPANY_SIZE, {canBeMissing: true}); const modal = useRef({}); const {isOnboardingCompleted} = useOnboardingFlowRouter(); + const [isOnboardingLoading] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {canBeMissing: true, selector: (value) => !!value?.isLoading}); + const prevIsOnboardingLoading = usePrevious(isOnboardingLoading); const [shouldShowRequire2FAPage, setShouldShowRequire2FAPage] = useState(!!account?.needsTwoFactorAuthSetup && !account.requiresTwoFactorAuth); const navigation = useNavigation(); @@ -248,6 +253,17 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie return CONFIG.IS_HYBRID_APP && Navigation.getActiveRoute().includes(ROUTES.ONBOARDING_ACCOUNTING.route) && isOnboardingCompleted === true; }, [isOnboardingCompleted]); + const shouldRenderOnboardingExclusively = useMemo(() => { + return ( + !CONFIG.IS_HYBRID_APP && + Navigation.getActiveRoute().includes(ROUTES.ONBOARDING_ACCOUNTING.route) && + getPlatform() !== CONST.PLATFORM.DESKTOP && + onboardingCompanySize !== CONST.ONBOARDING_COMPANY_SIZE.MICRO && + isOnboardingCompleted === true && + (!!isOnboardingLoading || !!prevIsOnboardingLoading) + ); + }, [onboardingCompanySize, isOnboardingCompleted, isOnboardingLoading, prevIsOnboardingLoading]); + useEffect(() => { NavBarManager.setButtonStyle(theme.navigationBarButtonsStyle); @@ -663,7 +679,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie options={rootNavigatorScreenOptions.basicModalNavigator} component={WelcomeVideoModalNavigator} /> - {(isOnboardingCompleted === false || shouldRenderOnboardingExclusivelyOnHybridApp) && ( + {(isOnboardingCompleted === false || shouldRenderOnboardingExclusivelyOnHybridApp || shouldRenderOnboardingExclusively) && ( { - if (!!isLoading || !prevIsLoading || !CONFIG.IS_HYBRID_APP) { + if (!!isLoading || !prevIsLoading) { return; } - HybridAppModule.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: true}); - setRootStatusBarEnabled(false); + if (CONFIG.IS_HYBRID_APP) { + HybridAppModule.closeReactNativeApp({shouldSignOut: false, shouldSetNVP: true}); + setRootStatusBarEnabled(false); + return; + } + openOldDotLink(CONST.OLDDOT_URLS.INBOX, true); }, [isLoading, prevIsLoading, setRootStatusBarEnabled]); const accountingOptions: OnboardingListItem[] = useMemo(() => { @@ -201,10 +205,7 @@ function BaseOnboardingAccounting({shouldUseNativeStyles}: BaseOnboardingAccount }); if (onboardingCompanySize !== CONST.ONBOARDING_COMPANY_SIZE.MICRO && getPlatform() !== CONST.PLATFORM.DESKTOP) { - if (CONFIG.IS_HYBRID_APP) { - return; - } - openOldDotLink(CONST.OLDDOT_URLS.INBOX, true); + return; } // Avoid creating new WS because onboardingPolicyID is cleared before unmounting InteractionManager.runAfterInteractions(() => { @@ -228,7 +229,7 @@ function BaseOnboardingAccounting({shouldUseNativeStyles}: BaseOnboardingAccount }); }} isLoading={isLoading} - isDisabled={isOffline && onboardingCompanySize !== CONST.ONBOARDING_COMPANY_SIZE.MICRO && CONFIG.IS_HYBRID_APP} + isDisabled={isOffline && onboardingCompanySize !== CONST.ONBOARDING_COMPANY_SIZE.MICRO && getPlatform() !== CONST.PLATFORM.DESKTOP} pressOnEnter />