Repository navigation
Conversation
|
@MelvinBot review |
Codex Review Summary: ✅ CompletedThis 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. |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
Review finding[P2] Reset the repair decision when switching accounts — useRepairExperienceCookie.ts:67–76 Starting as a Copilot sets Scope the decision to account initialization, or reset it when app freshness resets. Add coverage for Copilot → original-account restoration. Static review only; browser behavior was not verified. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ea3ccf886
ℹ️ 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".
| // Then only a known experience value is returned | ||
| expect(readExperienceCookie()).toBe(expected); |
There was a problem hiding this comment.
Add the required When sections to the new cookie tests
The three new test blocks include // Given and // Then, but none has a // When section. AGENTS.md explicitly requires all three, with comments explaining why each phase exists. Add the missing action section to these cases rather than combining invocation and assertion under Then.
AGENTS.md reference: AGENTS.md:L93-L93
Useful? React with 👍 / 👎.
|
|
||
| /** A start that keeps the user in New Expensify ends any back and forth, so the next mismatch in this tab can be repaired again */ | ||
| function releaseRepairInThisTab() { | ||
| if (typeof sessionStorage === 'undefined') { |
There was a problem hiding this comment.
Catch failures while resolving sessionStorage
When a browser denies Web Storage access, resolving the sessionStorage property can itself throw a SecurityError; typeof sessionStorage still invokes that getter. This probe is outside the try, as is the equivalent probe in claimRepairInThisTab, so the error escapes the new startup effect instead of safely skipping repair. This cleanup helper runs even when there is no new cookie, exposing ordinary shared-host initialization to the failure. Move both availability probes inside their protected access blocks.
Useful? React with 👍 / 👎.
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 the
experiencecookie. The Classic backend rewrites the cookie from the account's saved preference whenever it serves a page. Withexperience=newthe router sends the user to New Expensify, so the backend never gets that chance. If the preference changes to Classic while the cookie saysnew, the user stays in New Expensify for as long as the cookie lives, up to a year. This happens when the user switches to Classic in another browser, closes the tab while the switch is saving, or is removed from thehybridWebbeta.What changes
OpenApporReconnectAppresponse has been applied:newand the account in the beta prefers Classic: it opens Classic the same way switching does, which setsexperience=classicfirst.newand the account is no longer in the beta: it deletes the cookie and opens Classic, which then sends the user wherever it did before HybridWeb.newcookie the user reached New Expensify through a New Expensify-only link on purpose, and Classic fixes the cookie on the next visit to a shared path.hasFreshAppData, is set in the success data ofOpenAppandReconnectApp. It's only applied after a successful response and lands in the same Onyx update as the response data, so the check never decides on data cached by an earlier session. Requests that run outside the queue (GetMissingOnyxMessages, the side-effectReconnectApp) don't set it.sessionStorage. A start that keeps the user in New Expensify clears the record, so the next mismatch in that tab is repaired again. IfsessionStorageis unavailable, the check doesn't navigate.useOpenClassicignores a second call on expensify.com, because the first one already replaces the page. This covers the check and "Switch to Expensify Classic" finishing in the same queue flush.readExperienceCookieandisSharedProductHostare exported fromExperienceCookie, with no-op native versions.On new.expensify.com, its dev host and native, the check does nothing.
Known limits
shouldUseOldApp, the same rule native HybridApp uses, and it differs from the backend in two cases that fail safe. An account withisLockedToNewAppstays in New Expensify. So does aclassicRedirectwithout a booleandismissed, which the backend treats as Classic. In both cases the cookie isn't repaired and nothing loops.ReconnectAppdoesn't return betas, so removal from the beta is caught at the nextOpenApp: signing in, clearing the cache and then reloading, or a full reconnect.hasFreshAppDataisn't shared between tabs. A tab that isn't processing the request queue doesn't get it and doesn't repair the cookie.useOpenClassicon purpose, because a one-time visit must not change the cookie.This removes the blocker named in Write and clear the HybridWeb experience cookie when switching to Classic and signing out: "The router must stay off for the beta until this check ships."
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/700250
Tests
Prerequisites
main.hybridWebbeta, and a second local account to act as its Copilot. 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 in step 9.hybridWebbeta override in the app's Troubleshoot settings.tryNewDotNVP must havenudgeMigration, or Settings doesn't show "Switch to Expensify Classic", andclassicRedirect.dismissed: false. To reset it, run fromExpensidev/with your account ID and check the reply is200 OK: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'A signed-in app keeps its cached NVP until the next sign-in, so the steps sign in again after each reset.
/etc/hosts, change the existingexpensify.com.deventry, which points to the VM, to127.0.0.1. Restore it after testing.App/, runmkcert -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.There's no router locally, so the cookie is set by hand. On any page on
expensify.com.dev, including Classic, run this in the console:document.cookie = 'experience=new; Domain=.expensify.com.dev; Path=/; Max-Age=31536000; Secure; SameSite=Lax'Change
newtoclassicwhere a step says so. Turn on "Preserve log" in DevTools > Network and the "Verbose" level in the console. The once-per-tab record isEXPERIENCE_COOKIE_REPAIRunder DevTools > Application > Session storage >https://expensify.com.dev:8082.tryNewDotNVP and sign in with the beta account onhttps://expensify.com.dev:8082. Set the cookie tonewand reload the page.OpenOldDotLinkrequest is sent, and Session storage has noEXPERIENCE_COOKIE_REPAIR.https://expensify.com.dev:8082, press "Switch to Expensify Classic" in Settings and complete the survey. Close the private window once Classic opens.ReconnectAppresponse arrives, anOpenOldDotLinkrequest is sent and the tab openshttps://www.expensify.com.dev/inbox, and in Network theinboxdocument request hasexperience=classicin itsCookieheader.new, then openhttps://expensify.com.dev:8082in the same tab. Verify the tab stays in New Expensify, the console shows[ExperienceCookie] Not repairing the cookie again in this tab, and Session storage still hasEXPERIENCE_COOKIE_REPAIR.classicand reload the page. Verify the tab stays in New Expensify andEXPERIENCE_COOKIE_REPAIRis removed from Session storage.newand reload the page. Verify the tab opens Classic again.https://expensify.com.dev:8082in the same tab and wait until theReconnectApprequest has finished. Set the cookie tonew, block theReconnectApprequest URL in DevTools > Network request blocking and reload the page. Verify the tab stays in New Expensify whileReconnectAppfails. Remove the block and wait up to 10 seconds for the retry to succeed. Verify the tab opens Classic.https://expensify.com.dev:8082and sign out. Reset thetryNewDotNVP and revert theBetaManager.phpchange. On the sign-in page, set the cookie tonewand sign in again. Verify that afterOpenApp, theexperiencecookie is deleted beforeOpenOldDotLinkis sent, and theinboxdocument request carries noexperiencecookie. Classic then redirects to New Expensify on its own host, which is expected.BetaManager.phpchange. In Settings > Security of the beta account, add the second account as a Copilot. Sign in with the second account onhttps://expensify.com.dev:8082and switch to the beta account as its Copilot. Switch the beta account to Classic from a private window as in step 3, then set the cookie tonewin the first window and reload the page. Verify the tab stays in New Expensify and the cookie is stillnew.tryNewDotNVP and sign in with the beta account again. Set the cookie tonew, set throttling to "Slow 3G" in DevTools > Network and reload the page. BeforeReconnectAppfinishes, press "Switch to Expensify Classic" in Settings and complete the survey. Verify only oneOpenOldDotLinkrequest is sent and Classic opens once..envand/etc/hosts, restart the app withnpm run weband sign in with the beta account onhttps://dev.new.expensify.com:8082. Switch the account to Classic from a private window as in step 3 and reload the page. Verify noOpenOldDotLinkrequest is sent and the tab stays in New Expensify.Offline tests
tryNewDotNVP, sign in with the beta account onhttps://expensify.com.dev:8082and switch to Classic from a private window as in step 3 of the Tests.newand reload the page.ReconnectApporOpenOldDotLinkrequest is sent.ReconnectAppsucceeds, the tab opens Classic.QA Steps
Staging runs on staging.new.expensify.com and adhoc builds on their own test hosts, not on staging.expensify.com, so the check is off 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