@@ -35,8 +35,9 @@ function BookTravelButton({text}: BookTravelButtonProps) {
35
35
const policy = usePolicy ( activePolicyID ) ;
36
36
const [ errorMessage , setErrorMessage ] = useState ( '' ) ;
37
37
const [ travelSettings ] = useOnyx ( ONYXKEYS . NVP_TRAVEL_SETTINGS ) ;
38
- const [ account ] = useOnyx ( ONYXKEYS . ACCOUNT ) ;
39
- const primaryLogin = account ?. primaryLogin ;
38
+ const [ primaryLogin ] = useOnyx ( ONYXKEYS . ACCOUNT , { selector : ( account ) => account ?. primaryLogin } ) ;
39
+ const [ sessionEmail ] = useOnyx ( ONYXKEYS . SESSION , { selector : ( session ) => session ?. email } ) ;
40
+ const primaryContactMethod = primaryLogin ?? sessionEmail ?? '' ;
40
41
const { setRootStatusBarEnabled} = useContext ( CustomStatusBarAndBackgroundContext ) ;
41
42
42
43
// Flag indicating whether NewDot was launched exclusively for Travel,
@@ -47,7 +48,7 @@ function BookTravelButton({text}: BookTravelButtonProps) {
47
48
setErrorMessage ( '' ) ;
48
49
49
50
// The primary login of the user is where Spotnana sends the emails with booking confirmations, itinerary etc. It can't be a phone number.
50
- if ( ! primaryLogin || Str . isSMSLogin ( primaryLogin ) ) {
51
+ if ( ! primaryContactMethod || Str . isSMSLogin ( primaryContactMethod ) ) {
51
52
setErrorMessage ( translate ( 'travel.phoneError' ) ) ;
52
53
return ;
53
54
}
@@ -97,7 +98,7 @@ function BookTravelButton({text}: BookTravelButtonProps) {
97
98
Navigation . navigate ( ROUTES . TRAVEL_DOMAIN_SELECTOR ) ;
98
99
}
99
100
}
100
- } , [ policy , wasNewDotLaunchedJustForTravel , travelSettings , translate , primaryLogin , setRootStatusBarEnabled ] ) ;
101
+ } , [ policy , wasNewDotLaunchedJustForTravel , travelSettings , translate , primaryContactMethod , setRootStatusBarEnabled ] ) ;
101
102
102
103
return (
103
104
< >
0 commit comments