[NoQA] Fix missing areXEnabled defaults in new workspace optimistic Onyx data#91818
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a workspace-creation race where some areXEnabled policy flags were absent from the optimistic Onyx policy payload (showing up as undefined until the Auth/Pusher update arrives), by explicitly defaulting them to false and adding test coverage to prevent regressions.
Changes:
- Add
areInvoicesEnabled,areRulesEnabled, andarePerDiemRatesEnableddefaultfalsevalues to the optimistic policy data built during workspace creation. - Extend the existing “creates a new workspace” test to assert disabled-by-default feature flags are present and
falseimmediately after creation. - Remove
reimbursableTotalandunheldReimbursableTotalfrom the stableReportprojection (they are not part of theReportOnyx type).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/libs/actions/Policy/Policy.ts |
Ensures missing areXEnabled keys are included in optimistic workspace policy payload with false defaults. |
tests/actions/PolicyTest.ts |
Adds assertions validating the new defaults in optimistic Onyx state right after workspace creation. |
src/selectors/Report.ts |
Aligns the stable report selector’s projection with the Report type by removing non-existent fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
New workspaces were missing areInvoicesEnabled, areRulesEnabled, and arePerDiemRatesEnabled from their Onyx state until the async Pusher update from Auth arrived, because buildPolicyData never included these three properties in its optimistic payload. Co-authored-by: Cursor <cursoragent@cursor.com>
41ca6f4 to
7c4ab16
Compare
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / SafariMacOS: Desktop |
|
🚧 @mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.84-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes are required for this PR. This is a purely internal/technical fix that adds three missing boolean defaults ( @mountiny, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.86-0 🚀
Bundle Size Analysis (Sentry): |
|
I reviewed the changes in this PR. It adds three missing No help site changes are required. @mountiny, no help site PR is needed for this change since it's an internal-only fix with no user-facing impact. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.3.88-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes are required for this PR. This PR adds missing I reviewed the existing help site articles covering per diem, invoices, rules, and workspace creation, and they all remain accurate as-is. @mountiny, please review the linked help site PR and confirm it reflects the current behavior. Then mark the linked help site PR |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.3.88-2 🚀
|
Problem
When a new workspace is created from NewDot, three
areXEnabledpolicy properties were missing entirely from Onyx until the async Pusher update from Auth arrived:arePerDiemRatesEnabledareInvoicesEnabledareRulesEnabledThis caused these features to appear as
undefinedinstead offalsein the client, which could cause incorrect UI behavior (e.g. a toggle appearing enabled becauseundefinedis treated astrueby some fallbacks). The bug was reported forarePerDiemRatesEnabledon fresh staging accounts.Root Cause
buildPolicyDatainPolicy.tssets mostareXEnabledproperties optimistically when creating a workspace, but these three were never included. The backend (getDefaultPaidPolicyContentsinGenerator.php) correctly stores all of them asfalse, and Auth'sgetAsOnyxUpdatequeues the full policy payload to the owner's Pusher channel — but there was a window between workspace creation and the Pusher update landing where these three fields were absent from Onyx.Fixed issues
$ #91820
Add the three missing properties with their correct
falsedefaults to thebuildPolicyDataoptimistic payload, matching what the API stores. The comment above this block already calls this out:Testing
Added assertions to the existing
creates a new workspacetest inPolicyTest.tsto verify all disabled-by-defaultareXEnabledproperties are present in the optimistic Onyx state immediately after workspace creation.Fixed Issues
N/A
Tests
tests/actions/PolicyTest.ts—creates a new workspacenow assertsareInvoicesEnabled,areRulesEnabled, andarePerDiemRatesEnabledarefalsein the optimistic policy data.QA Notes
Create a fresh workspace from NewDot on staging. Before this fix, checking Onyx state (
policy_<ID>) immediately after creation would showarePerDiemRatesEnabled,areInvoicesEnabled, andareRulesEnabledas missing keys. After this fix they should all be present asfalse.PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))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.ScrollViewcomponent to make it scrollable when more elements are added to the page.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: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
Made with Cursor