-
Notifications
You must be signed in to change notification settings - Fork 4k
Fall back to the session email when account.primaryLogin is missing in BookTravelButton #100931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MelvinBot
wants to merge
3
commits into
main
Choose a base branch
from
claude-fixTravelPrimaryLoginFallback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+75
−7
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Onyx contains
account.primaryLogin === '',usePrimaryContactMethod()still returns the empty string because it uses??, so it never falls back to the valid session email andbookATripcontinues to show the contact-method error. This is a real account state—the repository explicitly handles it insrc/pages/settings/VerifyAccountPageBase.tsx:41-43—so the reported travel-blocking bug remains for those users; treat an empty primary login as missing here or update the hook to use the session email for this case.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MelvinBot please check this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — this is correct, and I've fixed it in 22fa38d.
usePrimaryContactMethod()used??, so anaccount.primaryLoginof''short-circuited the session-email fallback and returned''— the exact failure the PR set out to remove, just reached through a different Onyx state. The precedent you cite is real:src/pages/settings/VerifyAccountPageBase.tsx:41-43already uses||with the comment "sometimes primaryLogin can be empty string".I fixed the hook rather than patching
BookTravelButton, because all 13 call sites are contact-method flows (validate-code pages, card verification, travel) where''is never a usable value:Added four regression tests: empty
primaryLoginwith and without a session email intests/unit/hooks/usePrimaryContactMethod.test.ts, plus an empty-string case intests/unit/components/BookTravelButtonTest.tsx.The four pre-existing hook tests keep their expected values under
||, since none of them exercise a non-empty falsy input.One caveat: the sandbox on this run blocked me from executing Jest, ESLint, and typecheck locally, so CI is the first real verification of this commit. I'd hold off merging until the checks come back green.
view run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codex is right, and this is already fixed — commit
22fa38dlanded at 09:25 UTC, about 90 minutes after the comment, so the thread is just stale. No further change needed.I re-ran it as a negative control to be sure the finding was real rather than speculative. Reverting
src/hooks/usePrimaryContactMethod.ts:12from||back to??fails exactly the two empty-string tests and nothing else:With
||in place, 19/19 pass. SoprimaryLogin === ''really did slip through the original fix, and the follow-up closes it.On Codex's evidence, and one thing worth a reviewer's eye
The precedent Codex cites checks out.
src/pages/settings/VerifyAccountPageBase.tsx:41-43carries the comment "sometimes primaryLogin can be empty string" with aneslint-disableforprefer-nullish-coalescing— the same shape the fix now uses.src/pages/signin/SignInPage.tsx:247also falsy-checks it (!account?.primaryLogin).Caveat on how strong that evidence is: I could not find any code path in App that writes
primaryLogin: ''. The two writers I can see —setContactMethodAsDefaultand the HybridApp delegate path — both write a real value orundefined. The empty string would have to arrive from a sign-in API payload, so the two defensive sites above are the evidence, not a traceable write. The repo clone here is shallow, so I could not blame those lines back to the incident that prompted them. Either way the fix is harmless if the state never occurs, and correct if it does.Worth a sanity check before merge: the fix is in the shared hook, so it changes behavior for all 14 consumers, not just travel — the validate-code and card pages in
src/pages/settings/Wallet/,src/pages/workspace/expensifyCard/, andsrc/pages/workspace/companyCards/. In every one of those, an emptyprimaryLoginnow resolves to the session email instead of'', which is the strictly better outcome (they use it to address a validation code). I see no consumer that wants''. Fixing it in the hook rather than locally inBookTravelButtonalso matches theVerifyAccountPageBaseprecedent, so I think it is the right call — but the blast radius is wider than this PR's title suggests, and it is your call to confirm.One note: I could not verify any of this in a browser. Web prep failed on this run, so NewDot web could not be driven. Everything above is from the test suite and static analysis on
22fa38d.view run