Skip to content

[No QA] Read-only mode + hide archived policies in create/move flows - #97681

Merged
rlinoz merged 8 commits into
Expensify:mainfrom
c3024:chaitanya/97119-archive-readonly-hide-pickers
Aug 5, 2026
Merged

rlinoz merged 8 commits into
Expensify:mainfrom
c3024:chaitanya/97119-archive-readonly-hide-pickers

Conversation

@c3024

@c3024 c3024 commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Makes archived workspaces read-only and hides them from flows that create/move reports onto a workspace.

  • PolicyUtils.isArchivedPolicy() checks policy.archivedDate.
  • canMemberWrite() short-circuits to false for archived policies (read-only everywhere it already gates edits). canMemberRead() untouched.
  • getActivePolicies() / getActivePoliciesWithExpenseChat() exclude archived policies, so create flows never offer them.
  • shouldShowPolicy() gets includeArchivedPolicy (default false), threaded through useWorkspaceList(). Search's workspace filter and policyID autocomplete opt in with true to keep showing archived workspaces.

Fixed Issues

$ #97119

Tests

  • Verify that no errors appear in the JS console
  1. In Onyx (dev tools console), merge archivedDate: '2024-01-01' onto one of your workspaces' Policy object.
  2. Navigate to https://dev.new.expensify.com:8082/workspaces/<workspace-id> and verify that everything on the page is readonly. Switch to other options from the left panel and verify that all are readonly.
  3. Run Onyx.merge('reportNameValuePairs_<reportID>', {private_isArchived: '2024-01-01 00:00:00'}) in console to archive the expense chat of the workspace archived too.
  4. Try to create an expense/report, or move/change a report's workspace: confirm the archived workspace is absent from the picker.
  5. Open Search, filter by workspace: confirm the archived workspace still appears in the workspace filter.
  6. In Search, type a workspace: filter and open the policyID autocomplete: confirm the archived workspace still appears.
  7. Repeat with an active (non-archived) workspace as a control: everything above behaves normally (editable, appears in create/move pickers).
Screen.Recording.2026-08-03.at.7.34.49.PM.mov
Screen.Recording.2026-08-03.at.7.22.12.PM.mov
Screen.Recording.2026-08-03.at.7.34.06.PM.mov

Offline tests

Same as Tests — the change is a pure client-side Onyx read, no network calls involved, so offline behavior is unaffected.

QA Steps

This will be tested on R4 when the UI shows the archived workspaces.

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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-08-03.at.7.34.49.PM.mov
Screen.Recording.2026-08-03.at.7.22.12.PM.mov
Screen.Recording.2026-08-03.at.7.34.06.PM.mov

Adds isArchivedPolicy() and short-circuits canMemberWrite() so archived
workspaces become read-only everywhere policy-editing already gates
through it. Excludes archived policies from getActivePolicies() /
getActivePoliciesWithExpenseChat() so create-report flows never offer
them, and adds an includeArchivedPolicy opt-in to shouldShowPolicy()
(threaded through useWorkspaceList()) so most pickers hide archived
workspaces by default while Search's workspace filter and the policyID
autocomplete keep showing them.
@c3024 c3024 changed the title Read-only mode + hide archived policies in create/move flows [No QA] Read-only mode + hide archived policies in create/move flows Aug 3, 2026
@c3024

c3024 commented Aug 3, 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: fec2c8ba6b

ℹ️ 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/PolicyUtils.ts Resolved
Comment thread src/libs/PolicyUtils.ts Resolved
WorkspaceInitialPage now opts into includeArchivedPolicy so an archived
workspace's settings panel is still reachable by direct URL (the
Workspaces list keeps hiding it). WorkspaceOverviewPage additionally
treats an archived policy as read-only, reusing the page's existing
auditor read-only rendering rather than 404ing the page.
@codecov

codecov Bot commented Aug 3, 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/hooks/useAdvancedSearchFilters.ts 97.50% <ø> (ø)
src/hooks/useAutocompleteSuggestions.ts 73.00% <100.00%> (+9.50%) ⬆️
src/hooks/useWorkspaceList.ts 84.61% <100.00%> (+2.00%) ⬆️
src/libs/PolicyUtils.ts 77.53% <100.00%> (+0.25%) ⬆️
src/libs/ReportUtils.ts 86.69% <100.00%> (-0.01%) ⬇️
...ettings/CopyPolicySettingsSelectWorkspacesPage.tsx 83.07% <100.00%> (+0.26%) ⬆️
src/pages/workspace/WorkspaceInitialPage.tsx 0.00% <0.00%> (ø)
src/pages/workspace/rooms/WorkspaceRoomsPage.tsx 0.00% <0.00%> (ø)
.../pages/workspace/rooms/WorkspaceRoomCreatePage.tsx 0.00% <0.00%> (ø)
... and 285 files with indirect coverage changes

c3024 added 3 commits August 3, 2026 19:02
WorkspaceRoomsPage now hides the Create button (both layouts) when the
policy is archived; the rooms list itself stays visible and read-only.
WorkspaceRoomCreatePage blocks direct navigation to /rooms/new for an
archived policy via AccessOrNotFoundWrapper's shouldBeBlocked, showing
the standard not-found page instead.
The ADMIN access variant in AccessOrNotFoundWrapper only checked
canEditWorkspaceSettings, so admin-only edit RHPs without a
policyFeature (name, description, currency, client ID, share, plan
type, copy/duplicate settings, owner change) stayed reachable and
editable by direct URL on an archived workspace. Feature pages are
unaffected since ADMIN is filtered out of the checked variants whenever
policyFeature is set, gating on canMemberRead/canMemberWrite instead.
@c3024

c3024 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@c3024
c3024 marked this pull request as ready for review August 3, 2026 14:08
@c3024
c3024 requested review from a team as code owners August 3, 2026 14:08
@melvin-bot
melvin-bot Bot requested review from JmillsExpensify and daledah August 3, 2026 14:08
@melvin-bot

melvin-bot Bot commented Aug 3, 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 removed request for a team and JmillsExpensify August 3, 2026 14:08

@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: 64eb352439

ℹ️ 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/PolicyUtils.ts Resolved
Archived policies are now never editable at the source (PolicyUtils
canEditWorkspaceSettings), instead of the ADMIN access variant and
WorkspaceOverviewPage each checking isArchivedPolicy separately.
Removes the now-redundant isArchivedPolicy calls/imports from
AccessOrNotFoundWrapper and WorkspaceOverviewPage; behavior unchanged.
@c3024

c3024 commented Aug 3, 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: 10b972cf38

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

@daledah

daledah commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Bug: With exactly 2 workspaces, archiving one of them removes the workspace name prefix from both workspaces' reports - in the LHN preview line and in Search / autocomplete results. The still-active workspace is affected even though nothing was done to it.

bug.mov

Root cause: getReportSubtitlePrefix only shows the prefix when there are >= 2 visible policies, and it counts them with shouldShowPolicy(policy, false, currentUserLogin). Since this PR makes archived policies hidden by default, the count drops 2 -> 1 and the prefix is dropped for every report, not just the archived workspace's.

@daledah

daledah commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@c3024 We can still submit and approve expenses via the primary action button even though both the policy and the expense chat are archived. Is that expected?

Screen.Recording.2026-08-04.at.00.34.39.mov

@c3024

c3024 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Fixed this.

About this, expected for this PR because we are merging fields only into the expense chat and the policy. Report action gating is handled separately: backend guards land in the Release 2 "Block report state transitions" issue and the More menu allowlist in its own App issue. Also note the archived money report itself already hides Submit in production (ArchivePolicy archives the child reports too, which this Onyx-only repro doesn't).

@c3024

c3024 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@daledah Please check this and rereview.

@daledah

daledah commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@c3024 Archived workspaces can still be selected as a copy target.

CopyPolicySettingsSelectWorkspacesPage builds its eligible list with its own filter instead of going through getActivePolicies / shouldShowPolicy, so it doesn't pick up the new archived gate:

if (!policy || policy.id === sourcePolicyID || !isPaidGroupPolicy(policy) || isPendingDeletePolicy(policy) || !isPolicyAdmin(policy, currentUserEmail)) {

The design doc guards CopyPolicySettings on the target policy in Auth, so the user can pick an archived workspace and only find out when the backend fails with Policy is archived. Can we exclude them here as well?

@c3024

c3024 commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor Author

@daledah

Good catch, thanks! Fixed in bab42a5 — the eligible-targets filter in CopyPolicySettingsSelectWorkspacesPage now excludes archived policies.

@daledah

daledah commented Aug 5, 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 proper code patterns were followed (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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • 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 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 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.
  • 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

MacOS: Chrome / Safari
web-resize.mp4

@daledah daledah left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@melvin-bot
melvin-bot Bot requested a review from rlinoz August 5, 2026 08:27

@rlinoz rlinoz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, thanks!

@rlinoz rlinoz closed this Aug 5, 2026
@rlinoz rlinoz reopened this Aug 5, 2026
@rlinoz
rlinoz merged commit 0a0e504 into Expensify:main Aug 5, 2026
42 checks passed
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🚧 rlinoz has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

OSBotify commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify OSBotify mentioned this pull request Aug 5, 2026
46 tasks done
@OSBotify

OSBotify commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/rlinoz in version: 9.4.51-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.51-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

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.

5 participants