Skip to content

Apply approve-only permission checks to missed expense creation paths - #104929

Open
ShridharGoel wants to merge 8 commits into
Expensify:mainfrom
ShridharGoel:fix/approve-only-deploy-blockers
Open

ShridharGoel wants to merge 8 commits into
Expensify:mainfrom
ShridharGoel:fix/approve-only-deploy-blockers

Conversation

@ShridharGoel

@ShridharGoel ShridharGoel commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

The approve-only workspace role lets a member approve reports but not create expenses (#102933). The permission check canCreateExpensesOnPolicy was applied to the main expense creation flows, but a few older paths still only checked that the member has any role on the workspace. This PR applies the check to those paths:

  • Per diem and time workspace pickers: getActivePoliciesWithExpenseChat now excludes workspaces without the create-expense permission. This also fixes the start page counts that show the Per diem tab and auto-select a single workspace.
  • "Submit to my employer": the workspace count selector now excludes workspaces the member cannot create expenses on, so the flow no longer opens the confirm page of an approve-only workspace.
  • Report field: useOutstandingReports now applies the same permission filter as the report list, so the field is disabled when the list would be empty.
  • Next step: an open, empty report now shows "No further action" instead of "Waiting for you to add expenses" when the report owner cannot create expenses on the workspace.
  • Green brick road: the outstanding-child flag of the member's own empty report no longer shows the GBR when the member cannot create expenses on the workspace. Approve and pay badges still show.
  • Duplicate report: the copy now targets the default workspace when the source workspace is approve-only, and the button hides when there is no eligible default.
  • Default workspace after deletion: the optimistic fallback no longer picks an approve-only workspace as the new default, so the "Default" label no longer flashes on it.

Fixed Issues

$ #104917
$ #104914
$ #104907
$ #104903
$ #104902
$ #104945

Tests

Setup:

  1. User A creates a Control workspace and imports per diem rates to it.
  2. User A invites User B to the workspace.
  3. As User B, create a workspace of your own and set it as the default workspace.
  4. As User B, create two empty reports and one report with an expense in User A's workspace chat.
  5. User A changes User B's role on their workspace to Approve-only (workspace settings > Members).

Verify the fixes as User B:

  1. Per diem workspace picker: open FAB > Create expense > Per diem. Verify User A's workspace does not appear in the workspace list.
  2. Duplicate report: open the report with the expense in User A's workspace, then open More > Duplicate report. Verify the copy is created in your default workspace, with the expense and no error. Use a report with an expense, as in the issue's steps: an empty report has no expenses to copy, so it produces no visible copy. Do this step before step 10 deletes your default workspace. After that deletion, verify the Duplicate report option is hidden.
  3. Next step and GBR: open one of the empty reports created in step 4. Verify the next step shows "No further action" instead of "Waiting for you to add expenses", and the LHN shows no GBR on User A's workspace chat. Then have another member submit a report to you for approval and verify the Approve badge still shows in the LHN.
  4. Report field: create an expense in the self DM and tap Submit to my employer. Verify the flow does not open the confirm page of User A's workspace. Since no countable workspace remains, the flow creates a new Submit workspace, the same as for a user without a workspace. Then open a confirm page of an expense in the self DM and tap the Report field. Verify the Report field is disabled when the only outstanding reports are in User A's workspace, and enabled with a non-empty list otherwise. Also edit an expense that already sits in a report in User A's workspace: with exactly one outstanding report in another workspace, the Report field is enabled and that report can be picked.
  5. Default label: delete your own workspace. Verify User A's workspace never shows the Default label, not even briefly. The new default is an eligible workspace or the personal workspace.

Regression checks:

  1. As a regular member (no approve-only role), repeat steps 6, 7, 8, 9 and 10. Verify the behavior is unchanged: the workspace shows in the per diem picker, "Submit to my employer" routes to the only workspace, Duplicate report copies into the source workspace, deleting the default workspace picks the newest remaining group workspace, and "Waiting for you to add expenses" still shows on an open, empty report.
  • Verify that no errors appear in the JS console

Offline tests

  1. Turn off the network as the approve-only member and repeat the verify steps above. The permission checks read local data, so the results are the same.
  2. While offline, delete the default workspace. Verify the optimistic fallback still skips the approve-only workspace, with the same result after the request syncs.

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the ### Tests section
    • I added steps for the expected offline behavior in the ### Offline steps section
    • I added steps for Staging and/or Production testing in the ### QA steps section
    • I added steps to cover failure scenarios (i.e. verify that an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. If the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified that there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of the component in the rest of the App (i.e. If a shared library or component like Avatar is modified, I verified Avatar is working as expected in all cases)
  • If the PR modifies a component that can be accessed by a direct deeplink, I verified the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. adding new buttons or UI components, changing the padding/spacing/sizing, moving components, etc.) or modifies the form input styles:
    • I verified that the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the ### Tests steps.

Screenshots/Videos

MacOS: Chrome / Safari Screenshot 2026-10-24 at 7 11 33 PM
Screen.Recording.2026-10-24.at.7.16.30.PM.mov
Screenshot 2026-10-24 at 7 22 39 PM
Screen.Recording.2026-10-24.at.7.36.32.PM.mov
Screen.Recording.2026-10-24.at.7.46.23.PM.mov

@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
...eyRequestConfirmationList/sections/ReportField.tsx 77.77% <100.00%> (+0.41%) ⬆️
...MoneyRequestConfirmationList/sections/selectors.ts 85.71% <100.00%> (+0.27%) ⬆️
src/libs/NextStepUtils.ts 91.00% <100.00%> (+0.09%) ⬆️
src/libs/PolicyUtils/permissions.ts 100.00% <ø> (ø)
src/libs/PolicyUtils/policy.ts 84.81% <100.00%> (+0.29%) ⬆️
src/libs/ReportUtils.ts 90.25% <100.00%> (+0.02%) ⬆️
src/libs/actions/IOU/Duplicate.ts 93.26% <100.00%> (ø)
src/libs/actions/Policy/Policy.ts 73.43% <100.00%> (+0.15%) ⬆️
...es/iou/request/step/IOURequestEditReportCommon.tsx 87.15% <100.00%> (+0.33%) ⬆️
src/selectors/Policy.ts 88.55% <ø> (+0.66%) ⬆️
... and 2 more
... and 513 files with indirect coverage changes

@ShridharGoel
ShridharGoel marked this pull request as ready for review October 24, 2026 14:17
@ShridharGoel
ShridharGoel requested review from a team as code owners October 24, 2026 14:17
@melvin-bot
melvin-bot Bot requested review from Pujan92 and flaviadefaria and removed request for a team October 24, 2026 14:17
@melvin-bot

melvin-bot Bot commented Oct 24, 2026

Copy link
Copy Markdown

@Pujan92 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team October 24, 2026 14:17
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T14:34:01.842733Z 618e3ac Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 618e3ac982

ℹ️ 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".

Comment thread tests/actions/PolicyTest.ts Resolved
@ShridharGoel

Copy link
Copy Markdown
Contributor Author

@Pujan92 Did you get the chance to review this?

@ShridharGoel
ShridharGoel requested a review from flodnv November 1, 2026 12:10
…oy-blockers

# Conflicts:
#	src/components/MoneyRequestConfirmationList/sections/ReportField.tsx
#	src/hooks/useOutstandingReports.ts
#	src/pages/iou/request/step/IOURequestEditReportCommon.tsx
@Pujan92

Pujan92 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

@Pujan92

Pujan92 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@ShridharGoel we need to remove the temp block condition

@Pujan92

Pujan92 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

#104917 isn't solved yet as able to see that approve only workspace in the per diem flow My bad, I didn't reload the app

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants