Repository navigation
Guard against null workspace member entries in employeeList - #103793
Conversation
A null entry in policy.employeeList crashed getSuggestedSearchesVisibility, which SearchQueryProvider runs on every signed-in screen. Skip null entries there and in the other employeeList loops that read entries unguarded. Co-authored-by: Cong Pham <suneox@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
|
🤖 Web test steps verification results: On web, every screen the PR changes opened without a crash or error banner, including the Workflows > Approvals "Expenses from" picker after upgrading to Control. Only the JS console check is partial, because the tester couldn't read the browser console directly.
The null |
|
@MelvinBot A few updates before it's ready:
|
Co-authored-by: Cong Pham <suneox@users.noreply.github.com>
Codex Review SummaryThis 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. |
|
All five updates are done, and the PR is now ready for review.
All 148 tests in |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33334047db
ℹ️ 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".
|
|
||
| const isSubmittedTo = | ||
| !!currentUserEmail && Object.values(policy.employeeList ?? {}).some((employee) => employee.submitsTo === currentUserEmail || employee.forwardsTo === currentUserEmail); | ||
| !!currentUserEmail && Object.values(policy.employeeList ?? {}).some((employee) => employee?.submitsTo === currentUserEmail || employee?.forwardsTo === currentUserEmail); |
There was a problem hiding this comment.
Exclude null entries from member totals
When employeeList contains one real member and one null tombstone, this guard lets visibility calculation continue, but both isPolicyEligibleForTopSpenders() and memberCount still use Object.keys(...).length. The tombstone is therefore counted as a second member, incorrectly enabling the Top Spenders and Violations by Submitter suggestions even though there is nobody to compare; derive these counts from non-null, non-deleted employee values instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not needed here: the null entry only lives in the cache until reload and at most shows an extra suggestion, while this PR is scoped to the crash
|
The failing Analysis:
Evidence: This PR doesn't touch Next step: Add |
|
Nothing has changed since my earlier comment, so I still haven't pushed a fix.
|
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppNot required Android: mWeb ChromeNot required iOS: HybridAppNot required iOS: mWeb SafariNot required MacOS: Chrome / SafariCleanShot.2026-10-13.at.12.53.19.1.mp4 |
|
@MelvinBot merge main |
…yeeListEntries Co-authored-by: Cong Pham <suneox@users.noreply.github.com>
|
@suneox have you approved? |
dylanexpensify
left a comment
There was a problem hiding this comment.
Looks good from a product perspective 👍
|
@MelvinBot merge main |
…yeeListEntries Co-authored-by: Cong Pham <suneox@users.noreply.github.com> # Conflicts: # src/libs/WorkflowUtils.ts # tests/unit/WorkflowUtilsTest.ts
|
Merged Two files had conflicts: This PR still adds the null guards in |
|
@mountiny This PR is ready for review |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 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! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.16-0 🚀
|
|
No help site update is needed. This PR adds null checks so a missing workspace member entry no longer crashes the app, which is a bug fix with no change to any feature, label, or workflow described in the help articles. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.18-0 🚀
|
|
No help site update needed. This PR only adds null checks that stop the app from crashing on a bad workspace member entry, so it doesn't change any feature, label, or step that a help article describes. |
|
🚀 Deployed to production by https://github.com/grgia in version: 9.5.18-1 🚀
Bundle Size Analysis (Sentry): |














Explanation of Change
policy.employeeListcan hold anullentry, for example after Onyx applies several workspace updates in one batch.getSuggestedSearchesVisibilityreademployee.submitsToon every entry without a null check, so it threwCannot read 'submitsTo' of null.SearchQueryProviderruns that function on every render, and it wraps all signed-in screens, so one bad entry crashed the app (Sentry APP-J60).This PR:
getSuggestedSearchesVisibility, matching whatisPolicyApproveralready does.employeeListloops that read entries unguarded:includesEveryWorkspaceMemberandhasApprovalWorkflowWithNonMemberApproverinWorkflowUtils.ts, and three loops inDynamicWorkspaceWorkflowsApprovalsExpensesFromPage.tsx.convertPolicyEmployeesToApprovalWorkflowsandconvertApprovalWorkflowRulesToWorkflowsloops.hasApprovalWorkflowWithNonMemberApprovercalls these fromWorkspacesTabButtonon every screen whenever the multiple approvers beta is on or a member routes to someone no longer on the workspace.employeeListentry togetSuggestedSearchesVisibility,includesEveryWorkspaceMember, andhasApprovalWorkflowWithNonMemberApprover(with and without the multiple approvers beta). They fail onmainwith aTypeErrorand pass with this change.AI tests run: ESLint, typecheck, spell check, and the React Compiler check on the changed files passed. Jest passed for
SearchUIUtilsTest,WorkflowUtilsTest,WorkflowTest, and bothDynamicWorkspaceWorkflowsApprovalsExpensesFromPageUI tests. The oxfmt format check couldn't run in this environment, but every changed line stays under the 190-character print width.Fixed Issues
$ #103774
PROPOSAL: #103774 (comment)
Tests
Offline tests
QA Steps
Same as Tests.
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)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