1- import HybridAppModule from '@expensify/react-native-hybrid-app' ;
21import { Str } from 'expensify-common' ;
32import type { ReactElement } from 'react' ;
4- import React , { useCallback , useContext , useEffect , useState } from 'react' ;
3+ import React , { useCallback , useEffect , useState } from 'react' ;
54import { useOnyx } from 'react-native-onyx' ;
65import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' ;
76import useLocalize from '@hooks/useLocalize' ;
@@ -22,7 +21,6 @@ import ROUTES from '@src/ROUTES';
2221import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
2322import Button from './Button' ;
2423import ConfirmModal from './ConfirmModal' ;
25- import CustomStatusBarAndBackgroundContext from './CustomStatusBarAndBackground/CustomStatusBarAndBackgroundContext' ;
2624import DotIndicatorMessage from './DotIndicatorMessage' ;
2725import { RocketDude } from './Icon/Illustrations' ;
2826import Text from './Text' ;
@@ -62,7 +60,6 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se
6260 const [ travelSettings ] = useOnyx ( ONYXKEYS . NVP_TRAVEL_SETTINGS , { canBeMissing : false } ) ;
6361 const [ sessionEmail ] = useOnyx ( ONYXKEYS . SESSION , { selector : ( session ) => session ?. email , canBeMissing : false } ) ;
6462 const primaryContactMethod = primaryLogin ?? sessionEmail ?? '' ;
65- const { setRootStatusBarEnabled} = useContext ( CustomStatusBarAndBackgroundContext ) ;
6663 const { isBlockedFromSpotnanaTravel, isBetaEnabled} = usePermissions ( ) ;
6764 const [ isPreventionModalVisible , setPreventionModalVisibility ] = useState ( false ) ;
6865 const [ isVerificationModalVisible , setVerificationModalVisibility ] = useState ( false ) ;
@@ -72,7 +69,7 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se
7269 const groupPaidPolicies = activePolicies . filter ( ( activePolicy ) => activePolicy . type !== CONST . POLICY . TYPE . PERSONAL && isPaidGroupPolicy ( activePolicy ) ) ;
7370 // Flag indicating whether NewDot was launched exclusively for Travel,
7471 // e.g., when the user selects "Trips" from the Expensify Classic menu in HybridApp.
75- const [ wasNewDotLaunchedJustForTravel ] = useOnyx ( ONYXKEYS . IS_SINGLE_NEW_DOT_ENTRY , { canBeMissing : false } ) ;
72+ const [ hybridApp ] = useOnyx ( ONYXKEYS . HYBRID_APP , { canBeMissing : true } ) ;
7673
7774 const hidePreventionModal = ( ) => setPreventionModalVisibility ( false ) ;
7875 const hideVerificationModal = ( ) => setVerificationModalVisibility ( false ) ;
@@ -130,15 +127,14 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se
130127 openTravelDotLink ( policy ?. id )
131128 ?. then ( ( ) => {
132129 // When a user selects "Trips" in the Expensify Classic menu, the HybridApp opens the ManageTrips page in NewDot.
133- // The wasNewDotLaunchedJustForTravel flag indicates if NewDot was launched solely for this purpose.
134- if ( ! CONFIG . IS_HYBRID_APP || ! wasNewDotLaunchedJustForTravel ) {
130+ // The isSingleNewDotEntry flag indicates if NewDot was launched solely for this purpose.
131+ if ( ! CONFIG . IS_HYBRID_APP || ! hybridApp ?. isSingleNewDotEntry ) {
135132 return ;
136133 }
137134
138135 // Close NewDot if it was opened only for Travel, as its purpose is now fulfilled.
139136 Log . info ( '[HybridApp] Returning to OldDot after opening TravelDot' ) ;
140- HybridAppModule . closeReactNativeApp ( { shouldSignOut : false , shouldSetNVP : false } ) ;
141- setRootStatusBarEnabled ( false ) ;
137+ closeReactNativeApp ( { shouldSignOut : false , shouldSetNVP : false } ) ;
142138 } )
143139 ?. catch ( ( ) => {
144140 setErrorMessage ( translate ( 'travel.errorMessage' ) ) ;
@@ -175,8 +171,7 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se
175171 styles . link ,
176172 StyleUtils ,
177173 translate ,
178- wasNewDotLaunchedJustForTravel ,
179- setRootStatusBarEnabled ,
174+ hybridApp ?. isSingleNewDotEntry ,
180175 isUserValidated ,
181176 groupPaidPolicies . length ,
182177 isBetaEnabled ,
0 commit comments