Skip to content

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

Open
c3024 wants to merge 6 commits into
Expensify:mainfrom
c3024:chaitanya/97119-archive-readonly-hide-pickers
Open

[No QA] Read-only mode + hide archived policies in create/move flows#97681
c3024 wants to merge 6 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
Comment thread src/libs/PolicyUtils.ts
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

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

Files with missing lines Coverage Δ
src/hooks/useAdvancedSearchFilters.ts 97.50% <ø> (ø)
src/hooks/useAutocompleteSuggestions.ts 63.50% <100.00%> (ø)
src/hooks/useWorkspaceList.ts 84.61% <100.00%> (+2.00%) ⬆️
src/libs/PolicyUtils.ts 77.53% <100.00%> (+0.25%) ⬆️
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 70 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
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".

const policyID = route.params.policyID;
const policy = usePolicy(policyID);
const isAdmin = isPolicyAdmin(policy);
const isArchived = isArchivedPolicy(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 Block room detail edits for archived workspaces

When a workspace policy has archivedDate but its room reports are not also marked private_isArchived, this new isArchived value only hides the Create buttons; admins still use the existing row action keyed on isPolicyAdmin to open DynamicReportDetailsPage. Those room detail/settings/invite flows check the report archive state rather than policy.archivedDate, so an admin can still rename rooms, change write capability/visibility, invite/remove members, etc. Please also gate the room-details path or the room edit helpers on archived policies.

Useful? React with 👍 / 👎.

@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

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