@@ -17,6 +17,7 @@ import CONST from '@src/CONST';
1717import ONYXKEYS from '@src/ONYXKEYS' ;
1818import ROUTES from '@src/ROUTES' ;
1919import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
20+ import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue' ;
2021import Button from './Button' ;
2122import ConfirmModal from './ConfirmModal' ;
2223import DotIndicatorMessage from './DotIndicatorMessage' ;
@@ -48,10 +49,11 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se
4849 const styles = useThemeStyles ( ) ;
4950 const StyleUtils = useStyleUtils ( ) ;
5051 const { translate} = useLocalize ( ) ;
51- const [ activePolicyID ] = useOnyx ( ONYXKEYS . NVP_ACTIVE_POLICY_ID , { canBeMissing : false } ) ;
52+ const [ activePolicyID , activePolicyIDMetadata ] = useOnyx ( ONYXKEYS . NVP_ACTIVE_POLICY_ID , { canBeMissing : true } ) ;
5253 const [ account ] = useOnyx ( ONYXKEYS . ACCOUNT , { canBeMissing : true } ) ;
5354 const isUserValidated = account ?. validated ?? false ;
5455 const primaryLogin = account ?. primaryLogin ?? '' ;
56+ const isLoading = isLoadingOnyxValue ( activePolicyIDMetadata ) ;
5557
5658 const policy = usePolicy ( activePolicyID ) ;
5759 const [ errorMessage , setErrorMessage ] = useState < string | ReactElement > ( '' ) ;
@@ -172,6 +174,8 @@ function BookTravelButton({text, shouldRenderErrorMessageBelowButton = false, se
172174 onPress = { bookATrip }
173175 accessibilityLabel = { translate ( 'travel.bookTravel' ) }
174176 style = { styles . w100 }
177+ isLoading = { isLoading }
178+ isDisabled = { ! isLoading && ! activePolicyID }
175179 success
176180 large
177181 />
0 commit comments