Skip to content

Commit 92ffa92

Browse files
authored
Merge pull request #57560 from Expensify/rodrigo-fix-missing-email
Fallback primaryLogin with session's email for Book Travel
2 parents 237759d + b7434be commit 92ffa92

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/components/BookTravelButton.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ function BookTravelButton({text}: BookTravelButtonProps) {
3535
const policy = usePolicy(activePolicyID);
3636
const [errorMessage, setErrorMessage] = useState('');
3737
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 ?? '';
4041
const {setRootStatusBarEnabled} = useContext(CustomStatusBarAndBackgroundContext);
4142

4243
// Flag indicating whether NewDot was launched exclusively for Travel,
@@ -47,7 +48,7 @@ function BookTravelButton({text}: BookTravelButtonProps) {
4748
setErrorMessage('');
4849

4950
// 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)) {
5152
setErrorMessage(translate('travel.phoneError'));
5253
return;
5354
}
@@ -97,7 +98,7 @@ function BookTravelButton({text}: BookTravelButtonProps) {
9798
Navigation.navigate(ROUTES.TRAVEL_DOMAIN_SELECTOR);
9899
}
99100
}
100-
}, [policy, wasNewDotLaunchedJustForTravel, travelSettings, translate, primaryLogin, setRootStatusBarEnabled]);
101+
}, [policy, wasNewDotLaunchedJustForTravel, travelSettings, translate, primaryContactMethod, setRootStatusBarEnabled]);
101102

102103
return (
103104
<>

0 commit comments

Comments
 (0)