diff --git a/src/components/BookTravelButton.tsx b/src/components/BookTravelButton.tsx index 2c442df75060..c3e595164c3a 100644 --- a/src/components/BookTravelButton.tsx +++ b/src/components/BookTravelButton.tsx @@ -41,8 +41,9 @@ function BookTravelButton({text}: BookTravelButtonProps) { const policy = usePolicy(activePolicyID); const [errorMessage, setErrorMessage] = useState(''); const [travelSettings] = useOnyx(ONYXKEYS.NVP_TRAVEL_SETTINGS); - const [account] = useOnyx(ONYXKEYS.ACCOUNT); - const primaryLogin = account?.primaryLogin; + const [primaryLogin] = useOnyx(ONYXKEYS.ACCOUNT, {selector: (account) => account?.primaryLogin}); + const [sessionEmail] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session?.email}); + const primaryContactMethod = primaryLogin ?? sessionEmail ?? ''; const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext); const [isMaintenanceModalVisible, setMaintenanceModalVisibility] = useState(false); @@ -61,7 +62,7 @@ function BookTravelButton({text}: BookTravelButtonProps) { } // The primary login of the user is where Spotnana sends the emails with booking confirmations, itinerary etc. It can't be a phone number. - if (!primaryLogin || Str.isSMSLogin(primaryLogin)) { + if (!primaryContactMethod || Str.isSMSLogin(primaryContactMethod)) { setErrorMessage(translate('travel.phoneError')); return; } @@ -111,7 +112,7 @@ function BookTravelButton({text}: BookTravelButtonProps) { Navigation.navigate(ROUTES.TRAVEL_DOMAIN_SELECTOR); } } - }, [policy, wasNewDotLaunchedJustForTravel, travelSettings, translate, primaryLogin, setRootStatusBarEnabled]); + }, [policy, wasNewDotLaunchedJustForTravel, travelSettings, translate, primaryContactMethod, setRootStatusBarEnabled]); return ( <>