Skip to content

[Hold App/89963] [Bulk workspace edits] Add Copy Policy Settings select-workspaces page (step 1 of 3)#90079

Draft
fedirjh wants to merge 20 commits intoExpensify:mainfrom
fedirjh:copy-policy-settings-page-1
Draft

[Hold App/89963] [Bulk workspace edits] Add Copy Policy Settings select-workspaces page (step 1 of 3)#90079
fedirjh wants to merge 20 commits intoExpensify:mainfrom
fedirjh:copy-policy-settings-page-1

Conversation

@fedirjh
Copy link
Copy Markdown
Contributor

@fedirjh fedirjh commented May 8, 2026

Explanation of Change

Adds the entry point and the first RHP step of the new "Copy settings" flow that's part of the Bulk workspace edits project. This is task 3 of the project — task 1 (scaffold #89959) is merged; task 2 (action layer #89963) is still open and this PR is stacked on top of #89963. Please land #89963 first.

What this PR adds

  1. Three-dot menu entry in src/pages/workspace/WorkspacesListPage.tsx — a new "Copy settings" item with the Gear icon next to "Duplicate Workspace", visible only for admins (existing isAdmin guard). Navigates to ROUTES.POLICY_COPY_SETTINGS.

  2. Select Workspaces page in src/pages/workspace/copyPolicySettings/CopyPolicySettingsSelectWorkspacesPage.tsx — first step of the RHP flow. Renders a SelectionList with MultiSelectListItem of policies the current user is admin of, with the eligibility rules from the design doc:

    • Excludes the source policy
    • Excludes policies where the user is not admin and personal policies
    • When the source is CORPORATE, only CORPORATE targets are shown (Release 1 restriction; Issue 7 lifts this in R2 with an upgrade step)

    Layout:

  3. Translations — new workspace.copySettings.{title, selectWorkspaces, whichWorkspaces, searchPlaceholder, selectAll} block in all 10 language files.

  4. Sentry labelCONST.SENTRY_LABEL.WORKSPACE.COPY_SETTINGS_SELECT_WORKSPACES_SELECT_ALL for the select-all pressable.

The page reads its persisted state (targetPolicyIDs) directly from ONYXKEYS.COPY_POLICY_SETTINGS so re-entry restores the user's previous selection.

Fixed Issues

$ #88669
PROPOSAL: N/A

Tests

Setup

Sign in as an admin on at least two non-personal workspaces (a mix of Team/Collect and Corporate/Control if possible).

Test 1 — Three-dot menu entry

  1. Open the Workspaces list.
  2. Click the three-dot menu on a workspace where you're admin.
  3. Verify a new "Copy settings" item appears next to "Duplicate Workspace".
  4. Verify "Copy settings" uses the Copy/duplicate icon and "Duplicate Workspace" uses the Plus icon.
  5. Verify the item is not present on a workspace where you're not admin (or on personal workspaces).
  6. Click "Copy settings" → the RHP slides open with the "Select workspaces" step.

Test 2 — Eligibility filtering

  1. From a Corporate (Control) workspace, open Copy settings.
  2. Verify the list excludes the source workspace.
  3. Verify the list excludes any policy where you're not admin.
  4. Verify the list excludes any personal policy.
  5. Verify only other Corporate workspaces appear (Team workspaces are filtered out).
  6. Go back, repeat from a Team (Collect) workspace.
  7. Verify both Team and Corporate workspaces appear in the list.

Test 3 — Workspace avatars

  1. Open Copy settings.
  2. Verify each row shows the workspace avatar at the standard list-row size (not a tiny icon).
  3. For workspaces without an avatarURL, verify the default workspace avatar (initials/colored placeholder) is rendered.

Test 4 — Select-all alignment and behavior

  1. Open Copy settings.
  2. Verify the select-all checkbox sits on the right of its header row, aligned with the per-row checkboxes below it.
  3. Tap two rows — verify the select-all shows the indeterminate state.
  4. Tap the remaining rows — verify the select-all becomes fully checked.
  5. Tap the select-all checkbox — verify all rows clear.
  6. Tap the select-all label/checkbox again — verify all rows toggle on.

Test 5 — Search

  1. Open Copy settings on an account with 12 or fewer eligible workspaces.
  2. Verify no search input is shown.
  3. Open Copy settings on an account with more than 12 eligible workspaces.
  4. Verify a search input appears above the select-all header (search → select-all → rows order).
  5. Type part of a workspace name — verify the list filters case-insensitively.
  6. Type a string that matches nothing — verify the empty state ("No results found") is shown.
  7. Clear the input — verify the full list returns.

Test 6 — Next / commit selection

  1. Open Copy settings.
  2. With no rows selected, verify the "Next" button is disabled.
  3. Select one or more rows — verify "Next" becomes enabled.
  4. Click "Next" — verify the flow advances to the Select Features step (currently a stub page from this PR's scaffold).
  5. In dev tools / Onyx console, verify copyPolicySettings.targetPolicyIDs now contains the selected IDs and copyPolicySettings.sourcePolicyID is set.

Test 7 — Selection cleared on RHP close

  1. Open Copy settings, select 2–3 workspaces.
  2. Close the RHP via the X / back button without clicking "Next".
  3. Re-open Copy settings from the three-dot menu.
  4. Verify the previous selection is not restored (selection is empty, "Next" disabled).

Test 8 — Console

  • Verify that no errors appear in the JS console while running tests 1–7.

Offline tests

The page is a pure read of ONYXKEYS.COLLECTION.POLICY plus a useState selection; the only Onyx write happens at "Next" via setCopyPolicySettingsData. Both should work fully offline:

  1. Toggle off network connectivity.
  2. From the three-dot menu open Copy settings → the page renders with the cached policies, eligibility filtering still works.
  3. Toggle rows / select-all → state updates instantly.
  4. Click "Next" → the flow advances; verify copyPolicySettings.targetPolicyIDs is written to Onyx even while offline.
  5. Re-enable network — no redundant writes are queued (selection wasn't being persisted on every toggle).

QA Steps

Same as Tests 1–8 above on the staging environment.

  • 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 any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

fedirjh added 14 commits May 7, 2026 20:32
Adds the failure RBR message used when a bulk Copy Policy Settings
request fails. Defined across all ten language files so the
TranslationPaths type accepts it.
Implements the Onyx + API logic for the bulk Copy Policy Settings
flow. Exports:

- setCopyPolicySettingsData / clearCopyPolicySettings — Onyx helpers
- requestCopyPolicySettingsNotification — fires CopyPolicySettings_Notify
- PARTS_TO_POLICY_FIELDS — part key → list of Policy field names; drives
  pendingFields expansion so OfflineWithFeedback wrappers grey out
  per-tab during the copy
- buildCopyPolicySettingsData — produces optimistic/success/failure
  Onyx updates following the four-step algorithm in the design doc:
  field patch from source, per-target merge with snapshot rollback,
  SET-level overwrite of POLICY_CATEGORIES / POLICY_TAGS collection
  keys, and currentStep lifecycle on COPY_POLICY_SETTINGS
- copyPolicySettings — entry point that calls API.write

customUnits handling preserves each target's existing distance /
per-diem unit ID and only generates a new hex ID when the target has
no unit of that type yet.
Covers the four behaviors required by the design doc:
- each part key in isolation patches the right Policy fields and
  marks each one pending
- SET-level overwrite of POLICY_CATEGORIES and POLICY_TAGS collection
  keys, with failure data restoring the target's snapshot
- failure data restores the target's pre-copy field values
- customUnits preservation: target's existing distance / per-diem
  unit ID is reused; a new ID is generated only when absent
Switches from `import type * as OnyxCommon` to `import type {Errors}`
to satisfy the no-restricted-syntax rule that disallows namespace
imports from sibling modules.
Replaces `import * as` namespace imports for `@libs/API`,
`@libs/ErrorUtils`, and `@libs/NumberUtils` with named imports
(`write`, `getMicroSecondOnyxErrorWithTranslationKey`,
`generateHexadecimalValue`) to satisfy the no-restricted-syntax rule
that disallows namespace imports from `@libs`. Also picks up a
prettier formatting fix in the test import.
Renames the placeholder custom unit IDs (`SOURCEDISTID`,
`SOURCEPERDIEM`, `TARGETDISTID`, `TARGETPERDIEMID`) to digit-only
13-character strings so cspell stops flagging them as unknown words.
The strings remain valid `[0-9A-F]{13}` hex IDs and tests still pass.
Includes a JSDoc comment to clarify the purpose of the sourcePolicyID field, indicating that it represents the ID of the source policy from which settings are copied.
Adds title, selectWorkspaces, whichWorkspaces, searchPlaceholder, and
selectAll keys for the new "Copy settings" RHP flow's first step,
across all ten language files.
Adds a new "Copy settings" item next to "Duplicate Workspace" in the
admin three-dot menu on WorkspacesListPage. Uses the Gear icon and
navigates to ROUTES.POLICY_COPY_SETTINGS, the first step of the new
RHP flow. Visible only for admins (existing isAdmin guard).
First RHP step of the bulk Copy Policy Settings flow. Renders a
SelectionList with MultiSelectListItem of policies the current user
is admin of, excluding:

- the source policy
- personal policies
- policies where the user is not admin
- when the source is Corporate, non-Corporate targets (Release 1
  restriction; Issue 7 lifts this with an upgrade step)

Layout follows the design doc:
- select-all Checkbox above the list (indeterminate when partial)
- SearchBar appears only when there are more than 12 eligible
  workspaces
- "Next" persists targetPolicyIDs through setCopyPolicySettingsData
  and routes to POLICY_COPY_SETTINGS_SELECT_FEATURES; disabled until
  at least one workspace is selected

Adds CONST.SENTRY_LABEL.WORKSPACE.COPY_SETTINGS_SELECT_WORKSPACES_SELECT_ALL
for the select-all pressable.
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented May 8, 2026

Hey, I noticed you changed src/languages/en.ts in a PR from a fork. For security reasons, translations are not generated automatically for PRs from forks.

If you want to automatically generate translations for other locales, an Expensify employee will have to:

  1. Look at the code and make sure there are no malicious changes.
  2. Run the Generate static translations GitHub workflow. If you have write access and the K2 extension, you can simply click: [this button]

Alternatively, if you are an external contributor, you can run the translation script locally with your own OpenAI API key. To learn more, try running:

npx ts-node ./scripts/generateTranslations.ts --help

Typically, you'd want to translate only what you changed by running npx ts-node ./scripts/generateTranslations.ts --compare-ref main

@fedirjh fedirjh changed the title Add Copy Policy Settings select-workspaces page (step 1 of 3) [Hold App/89963] [Bulk workspace edits] Add Copy Policy Settings select-workspaces page (step 1 of 3) May 8, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

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/components/SelectionList/BaseSelectionList.tsx 64.80% <ø> (ø)
...components/SelectionList/components/ListHeader.tsx 90.00% <100.00%> (+1.76%) ⬆️
src/pages/workspace/WorkspacesListPage.tsx 72.72% <0.00%> (-0.18%) ⬇️
src/libs/actions/Policy/CopyPolicySettings.ts 86.59% <86.59%> (ø)
...ettings/CopyPolicySettingsSelectWorkspacesPage.tsx 0.00% <0.00%> (ø)
... and 147 files with indirect coverage changes

fedirjh added 6 commits May 8, 2026 22:11
Per review on PR Expensify#90079: use the Plus icon for "Duplicate workspace"
and the Copy (duplicate) icon for "Copy settings", to better match
each item's intent.
Per review on PR Expensify#90079: MultiSelectListItem renders its checkbox on
the right side, so move the select-all Checkbox to the right of the
header row (label on the left, checkbox on the right) so they line up
with the per-row checkboxes below.
Drops the separate SearchBar component above the list in favour of
SelectionList's built-in textInputOptions, which matches the search
field used in the New Chat / start chat flow at /new/chat. The
built-in input owns its own margin/padding so the design is
consistent across the app.

The "more than 12 eligible workspaces" gate is preserved by toggling
shouldShowTextInput.
The built-in select-all header always rendered its checkbox on the
left, which misaligned with lists whose per-row checkboxes use
selectionButtonPosition=RIGHT (e.g. MultiSelectListItem).

Adds a selectionButtonPosition prop to ListHeader (default LEFT for
existing callers) and threads it from BaseSelectionList. When set to
RIGHT, the label/checkbox order is swapped and the row uses
justifyContentBetween so the checkbox sits flush right, matching the
list rows below.
Three review fixes on the Select Workspaces page:

- Use SelectionList's built-in onSelectAll with
  selectionButtonPosition=RIGHT, so the search input sits above the
  select-all header and the select-all checkbox lines up with the
  per-row checkboxes (both on the right). Drops the custom select-all
  header that used to sit above the SelectionList.
- Render the workspace avatar at AVATAR_SIZE.DEFAULT via a leftElement
  on each list item. The previous icons-based path inside
  MultiSelectListItem hardcodes AVATAR_SIZE.SMALLER, which looked too
  small. Falls back to getDefaultWorkspaceAvatar when avatarURL is
  missing.
- Track selectedTargetIDs in local useState instead of writing to
  COPY_POLICY_SETTINGS on every toggle. The Onyx key is now updated
  only when the user confirms "Next", so closing the RHP mid-flow
  naturally drops the in-progress selection without needing a manual
  clear-on-mount.
The page now uses SelectionList's built-in select-all header, which
already reuses workspace.people.selectAll for its label and
SENTRY_LABEL.SELECTION_LIST.LIST_HEADER_SELECT_ALL for its pressable.
The custom workspace.copySettings.selectAll key (10 language files)
and SENTRY_LABEL.WORKSPACE.COPY_SETTINGS_SELECT_WORKSPACES_SELECT_ALL
are no longer referenced — remove them.
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