Skip to content

Restrict report state transitions to archived policies only - #98948

Open
c3024 wants to merge 9 commits into
Expensify:mainfrom
c3024:chaitanya/98868-restrict-more-menu-archived-policies
Open

Restrict report state transitions to archived policies only#98948
c3024 wants to merge 9 commits into
Expensify:mainfrom
c3024:chaitanya/98868-restrict-more-menu-archived-policies

Conversation

@c3024

@c3024 c3024 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Report state transitions (Submit, Approve, Pay, Unapprove, Cancel payment, Retract, Reopen) are now hidden only when the report's policy is archived, keyed on isArchivedPolicy. Reports archived for other reasons, such as the submitter being removed from the workspace, keep these actions so their outstanding reports can still be approved and paid. IOU and invoice reports keep the existing archived report checks because they have no policy archived state. The same keying is applied to canIOUBePaid, canApproveIOU and the report preview actions, which drive the preview button and the settlement button payment options.

Fixed Issues

$ #98868

PROPOSAL:

Tests

Removed member flow:

  1. As an admin, create a Control workspace with approvals enabled (Submit and Approve) and invite a member.
  2. As the member, create an expense on the workspace and submit the report.
  3. As the admin, remove the member from the workspace.
  4. As the admin, open the workspace chat and verify the report preview shows the Approve button.
  5. As the admin, open the removed member's submitted expense report.
  6. Verify the Approve action is available (header button or More menu) and approve the report.
  7. Verify the report preview and the report header show a Pay button with payment options and pay the report.

Archived policy flow:

  1. Create a workspace and add a member.
  2. As the member, submit an expense.
  3. As admin, run Onyx.merge('policy_<policyID>', {archivedDate: '2026-01-01'}) with the policyID created in step 1.
  4. Open the report and verify Approve, Pay, Unapprove, Cancel payment, Retract, and Reopen do not appear in the header, the More menu, or the report preview.
Screen.Recording.2026-08-19.at.8.35.22.PM.mov
Screen.Recording.2026-08-19.at.8.32.06.PM.mov
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests.

QA Steps

Same as above.

  • 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 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 only 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 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.
  • 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 Test steps.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-08-19.at.8.35.22.PM.mov
Screen.Recording.2026-08-19.at.8.32.06.PM.mov

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/libs/PolicyUtils.ts 77.71% <100.00%> (+0.03%) ⬆️
src/libs/ReportPrimaryActionUtils.ts 94.23% <100.00%> (+0.46%) ⬆️
src/libs/ReportSecondaryActionUtils.ts 96.23% <100.00%> (+0.47%) ⬆️
src/libs/SearchUIUtils.ts 67.08% <100.00%> (-0.03%) ⬇️
src/libs/TodosUtils.ts 95.71% <100.00%> (ø)
src/libs/ReportPreviewActionUtils.ts 91.66% <83.33%> (-1.56%) ⬇️
src/libs/actions/IOU/ReportWorkflow.ts 82.46% <80.00%> (-0.24%) ⬇️
... and 51 files with indirect coverage changes

c3024 added 4 commits August 19, 2026 16:17
…ict-more-menu-archived-policies

# Conflicts:
#	tests/unit/ReportPrimaryActionUtilsTest.ts
#	tests/unit/ReportSecondaryActionUtilsTest.ts
…ict-more-menu-archived-policies

# Conflicts:
#	src/libs/ReportPreviewActionUtils.ts
#	src/libs/actions/IOU/ReportWorkflow.ts
@c3024
c3024 marked this pull request as ready for review August 19, 2026 15:19
@c3024
c3024 requested review from a team as code owners August 19, 2026 15:19
@melvin-bot
melvin-bot Bot requested review from daledah and removed request for a team August 19, 2026 15:19
@melvin-bot

melvin-bot Bot commented Aug 19, 2026

Copy link
Copy Markdown

@daledah 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 requested review from dylanexpensify and removed request for a team August 19, 2026 15:19

@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: 1f32667f64

ℹ️ 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 src/libs/ReportPrimaryActionUtils.ts Outdated
@c3024

c3024 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

@codex review.

@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: 9a7700cc17

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


// State transitions are blocked only on archived or pending-delete policies. Reports archived for other reasons
// (e.g. the submitter was unshared from the policy) can still move through the workflow.
if (isArchivedOrPendingDeletePolicy(policy)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use the policy archive gate for Search submissions

When an open expense report is archived because its submitter was removed from an otherwise active workspace, the new header and preview predicates allow Submit, but Search still calls canSubmitReport() with isIOUReportArchived || isChatReportArchived in SearchUIUtils.ts:2600; canSubmitReport() rejects that value at line 330. As a result, an admin can submit the removed member's report from the report view but not from Search or bulk actions. Apply isArchivedOrPendingDeletePolicy(policy) to the submit predicate too rather than retaining the NVP-based archive check.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 3a2bffb. Search submit now passes isArchivedOrPendingDeletePolicy(policy) to canSubmitReport instead of the report NVP archive flags.

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.

1 participant