Do not seed My expenses saved search for approve-only accounts - #97417
Draft
aswin-s wants to merge 2 commits into
Draft
Do not seed My expenses saved search for approve-only accounts#97417aswin-s wants to merge 2 commits into
aswin-s wants to merge 2 commits into
Conversation
The submitter half of isSubmitterAndApprover was derived from isGroupPolicy, a check on policy.type that never looks at the current user. The POLICY Onyx collection only holds policies the user belongs to, so it was true for anyone in a group workspace and eligibility collapsed to "is an approver somewhere". Gate on the admin/auditor role instead, matching the admin-facing suggested searches. Being an approver is not recorded on the approver's own employee entry, and the default workflow gives every member a submitsTo target, so role is the only signal that separates a manager from a plain member who happens to approve someone.
aswin-s
force-pushed
the
fix/issue-97213-follow-up
branch
from
July 30, 2026 01:23
f420560 to
19b117e
Compare
7 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Explanation of Change
Follow-up to #93541, which seeded the "My expenses" saved search on approve-only accounts.
The submitter half of
isSubmitterAndApproverwas derived fromisGroupPolicy(policy)— a check onpolicy.typethat never looks at the current user:The
POLICYOnyx collection only holds policies the user belongs to, so this was true for anyone in any group workspace. Eligibility therefore collapsed to "is an approver somewhere", and the approve-only account in the linked issue satisfied it: member of the workspace ⇒isSubmitter, set as the submitter's approver in workflow ⇒isApprover.This also explains why the submit-only case in #93541's test steps passed — only the approve-only half of the condition was broken, so manual testing did not surface it.
This PR gates the first half on the admin/auditor role instead, matching the
isAdmin || isAuditorcheck the admin-facing suggested searches already use ingetSuggestedSearchesVisibility. Any member of a group workspace can file their own expenses, so managing a workspace covers the "submits" half of the audience #92780 describes.Notes for reviewers on why
roleis the signal used, since two more obvious candidates do not work:employeeListentry — it is an inbound reference from whoever submits to them. The default workflow also gives every member asubmitsTotarget (members route to the owner, the owner to themselves), so requiring one does not exclude the reported account.isPolicyExpenseChatEnabled+ membership is also true for it. Gating on whether the user has expenses was rejected separately: a newly-added manager with no expenses yet should still be seeded.Three existing unit tests asserted the old behaviour (including one named "any member is a submitter, not just role=user") and have been corrected.
Fixed Issues
$ #97213
PROPOSAL:
Tests
Preconditions: 3 accounts (1 workspace owner, 1 submitter, 1 approver).
from:<owner account ID>.Failure scenario: with the network throttled or offline at step 6, the entry appears optimistically and rolls back if the
SaveSearchwrite fails, matching the existing manual save-search behaviour.Offline tests
Unchanged from #93541. The seed uses the existing
saveSearchwrite path, which has optimistic data plus failure rollback, so offline behaviour is identical to saving a search manually while offline: the entry appears optimistically and syncs when back online. This PR only narrows which accounts are eligible and adds no new network calls.QA Steps
Same as tests. The key assertion is step 4 — the approve-only account must not receive the seeded search — and step 6, which confirms the eligible dual-role account still does.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, 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.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
Verified on a real 3-account workspace against the dev backend (owner + submitter + approver, with a workflow routing the submitter to the approver):
useradmintype:expense from:<accountID>For the approver,
nvp_hasSeededMyExpensesSearchandnvp_savedSearchesboth remained unset and no Saved section rendered. For the owner, the NVP was set and the entry appeared in the Saved section.