Repository navigation
[no qa][Payment due @nkdengineer] Write and clear the HybridWeb experience cookie when switching to Classic and signing out - #106411
Conversation
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@MelvinBot review |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Found two issues:
Validation: All 18 tests across the three new unit suites passed. Findings are based on source tracing; no browser reproduction performed. |
|
Hi! We are aware Melvin tester runs are failing. Please if you could update this branch to latest main and re-run it - this should resolve the issue. If not, reach out to me directly. Thanks for your patience! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 537cae959c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…s the exit survey
…-experience-cookie
|
@codex review |
|
Both earlier findings are addressed. One remaining issue: [P2] Overlapping switches can leave a successful request showing an error. In ExitSurvey.ts:24–41, success clears loading but not errors. If two tabs submit switches before either completes, and the first fails while the second succeeds, the buffered updates retain the first request’s error. The second tab then classifies its successful switch as failed, displays an error, and never opens Classic. Clear errors on success and associate completion with the initiating request. Add a regression test covering overlapping failure→success responses. Validation: All 155 tests across six related suites passed. This finding is based on source tracing; no browser reproduction performed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3b97d53915
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
…-experience-cookie
|
@jakubstec can you first fix ci? |
|
@AndrewGable done! |
|
@AndrewGable Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
JmillsExpensify
left a comment
There was a problem hiding this comment.
all good on my end
| size={CONST.BUTTON_SIZE.LARGE} | ||
| sentryLabel={CONST.SENTRY_LABEL.SETTINGS_EXIT_SURVEY.GO_TO_CLASSIC} | ||
| onPress={goToExpensifyClassic} | ||
| onPress={() => switchToClassic(exitSurveyResponse)} |
There was a problem hiding this comment.
Since useSwitchToClassic only calls openClassic after the API is successful, if we close the screen before it's done, Classic never opens. Should we block closing the screen while a switch is saving and we're not offline?
There was a problem hiding this comment.
I think it's bad UX to block it. Closing the screen doesn't cancel the switch, since the server still saves it. In a follow-up PR, we will handle the misalignment between NVP and the experience cookie
| const WWW_PREFIX = 'www.'; | ||
|
|
||
| // The server writes the same cookie, so the attributes must match or the browser keeps two copies. It's not HttpOnly so New Expensify can update it. | ||
| const COOKIE_ATTRIBUTES = 'Path=/; Secure; SameSite=Lax'; |
There was a problem hiding this comment.
From the design doc: the cookie from the server is set as HttpOnly while here it's not HttpOnly. @AndrewGable, can you please confirm?
Set-Cookie: experience=new; Max-Age=31536000; Domain=.expensify.com; Path=/; Secure; HttpOnly; SameSite=Lax
There was a problem hiding this comment.
further down, the design doc also says that if a user switches from New to Classic, we will update the cookie before the browser navigates to OldDot, so the App has to do it directly using document.cookie. If it were an HttpOnly cookie, it would be blocked, so I assume it's the correct way
There was a problem hiding this comment.
Yeah, no HttpOnly I believe.
|
@jakubstec Please resolve conflicts. |
…-experience-cookie # Conflicts: # src/libs/actions/SignInRedirect.ts
|
@nkdengineer done! |
|
@jakubstec Please update test steps to notice that the button shows loading instead of disabling. Thanks. |
|
@nkdengineer updated, thanks! |
|
@jakubstec Since the QA can't do anything here, please update the title with [No QA] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2026-11-13.at.22.43.34.movScreen.Recording.2026-11-13.at.22.48.52.mov |
|
🎯 @nkdengineer, thanks for reviewing and testing this PR! 🎉 A payment issue will be created for your review once this PR is deployed to production. If payment is not needed (e.g., regression PR review fix etc), react with 👎 to this comment to prevent the payment issue from being created. |
|
🚧 AndrewGable has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/AndrewGable in version: 9.5.40-0 🚀
|
|
No help site update needed — the cookie changes are beta-gated or internal, and the remaining switching reliability fixes do not introduce a new workflow or make any existing article sentence incorrect. |
Explanation of Change
Context. expensify.com is going to serve both products from one address. A router in front of it picks New Expensify or Expensify Classic based on a cookie named
experience, set toneworclassic. The Classic backend sets this cookie whenever it serves a Classic page. Switching to Classic and signing out only call the API from New Expensify, and those requests omit cookies, so the browser also ignores any cookie in the response. The backend can't set the cookie for these two actions, so New Expensify writes it itself.What changes
experience=classicright before Classic opens.useSwitchToClassicsaves the switch and then opens Classic.useOpenClassicsets the cookie and opens Classic.hybridWebbeta, and never in Supportal or Copilot sessions or when an agent starts one, so an agent's own cookie stays intact.On new.expensify.com this code intentionally does nothing, because the cookie only matters when New Expensify and Classic share expensify.com, so there the only change is that Classic opens after the switch is saved.
Follow-ups, not in this PR
newwhile the server already saved Classic. The router must stay off for the beta until this check ships.Fixed Issues
$ https://github.com/Expensify/Expensify/issues/700250
Tests
Prerequisites
hybridWebbeta. Locally every account has theallbeta, which doesn't include the explicit-onlyhybridWeb, so in the VM setprivate static array $toggledBetas = [self::BETA_HYBRID_WEB];inWeb-Expensify/lib/BetaManager.phpand sign in again. Revert it for step 11.tryNewDotNVP must havenudgeMigration, or Settings doesn't show "Switch to Expensify Classic", andclassicRedirect.dismissed: false, or the exit survey is skipped. To reset it, run fromExpensidev/with your account ID:printf '%s\n' 'Query' "query: UPDATE nameValuePairs SET value='{\"classicRedirect\":{\"dismissed\":false},\"nudgeMigration\":{\"timestamp\":\"2026-10-01T00:00:00.000Z\"}}' WHERE accountID=<accountID> AND name='tryNewDot';" 'format: json' '' | vagrant ssh -- -T '(cat; sleep 3) | nc -q 1 127.0.0.1 4444'/etc/hosts, change the existingexpensify.com.deventry, which points to the VM, to127.0.0.1. Restore it after testing.mkcert -cert-file config/rsbuild/certificate.pem -key-file config/rsbuild/key.pem dev.new.expensify.com expensify.com.dev localhost 127.0.0.1..env, setNEW_EXPENSIFY_URL=https://expensify.com.dev:8082/,EXPENSIFY_URL=https://www.expensify.com.dev/andUSE_WEB_PROXY=false.npm run web-server -- --host expensify.com.dev.Classic pages also write the cookie from the server. To see what New Expensify wrote, turn on "Preserve log" in DevTools > Network and check the
Cookieheader of the request that opens Classic (/inbox).SwitchToOldDotis pending, "Switch to Expensify Classic" shows a spinner and "Go back just once" is disabled, and Classic opens only after the response arrives.experience=classic, and DevTools > Application > Cookies shows oneexperience=classiccookie withDomain=.expensify.com.dev,Path=/,Secure,SameSite=Laxand noHttpOnly.SwitchToOldDotsucceeds, and the request that opens Classic carriesexperience=classic.SwitchToOldDotrequest, and the request that opens Classic carriesexperience=classic.tryNewDotNVP, open New Expensify in two tabs and switch through the exit survey from the newer tab. Verify Classic opens after theSwitchToOldDotresponse arrives.tryNewDotNVP and open New Expensify in two tabs. Throttle the network in the first tab, switch through the exit survey and, while it's saving, open the exit survey in the second tab. Verify the first tab opens Classic only after itsSwitchToOldDotresponse arrives, and the second tab stays on the survey with an empty response field.tryNewDotNVP and, inWeb-Expensify/api.php, addthrow new ExpException('Testing a failed switch', 402);as the first line ofcase 'SwitchToOldDot':. Switch through the exit survey. Verify an error toast shows, the survey answer is kept, the spinner stops, both buttons can be pressed again and the cookie is unchanged. Remove the line and press "Switch to Expensify Classic" again. Verify Classic opens.tryNewDotNVP, open the exit survey and press "Go back just once". Verify Classic opens without aSwitchToOldDotrequest, and the request that opens Classic carries the sameexperiencevalue as before.experience=newon.expensify.com.devin DevTools and sign out of New Expensify. Verify noexperiencecookie is left.BetaManager.phpchange, sign in again and repeat steps 1 and 10. Verify the request that opens Classic doesn't carry a cookie written by New Expensify, and signing out deletes the cookie, like the backend does.experience=newin DevTools, then start a Supportal session for another account from Classic. Verify the cookie is stillnew.https://dev.new.expensify.com:8082and repeat steps 1 and 10. Verify the request that opens Classic carries noexperiencecookie, and signing out leaves an existing cookie in place.Offline tests
tryNewDotNVP, sign in with the beta account and go offline.SwitchToOldDotrequest is sent, theexperiencecookie isclassic, and New Expensify starts opening Classic, which can't load while offline.QA Steps
Staging runs on staging.new.expensify.com and adhoc builds on their own test hosts, not on staging.expensify.com, so the cookie isn't written there and only the switching flow can be checked.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari