Skip to content

[Bulk workspace edits] Add Copy Policy Settings Double-check confirmation page (step 3 of 3)#91241

Merged
yuwenmemon merged 45 commits into
Expensify:mainfrom
fedirjh:copy-policy-settings-page-3
Jun 1, 2026
Merged

[Bulk workspace edits] Add Copy Policy Settings Double-check confirmation page (step 3 of 3)#91241
yuwenmemon merged 45 commits into
Expensify:mainfrom
fedirjh:copy-policy-settings-page-3

Conversation

@fedirjh

@fedirjh fedirjh commented May 20, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This PR implements the Page 3 (Double-check confirmation step) of the "Bulk Workspace Edits" feature as outlined in Issue #88672.

Key changes:

  1. Centralized Feature Rows Definition: Moved FEATURE_ROWS out of CopyPolicySettingsSelectFeaturesPage.tsx and centralized it in src/libs/CopyPolicySettingsUtils.ts, exporting it so it can be cleanly reused by both pages.
  2. Page 3 Confirm Page (CopyPolicySettingsConfirmPage.tsx): Created the confirm screen showing a descriptive header/subheader, a "Configuration" list of translated, selected features to copy (pointing back to feature selection page), and a "Workspaces" list of selected target workspaces (pointing back to workspace selection page). Clicking the success button calls copyPolicySettings and dismisses the modal flow.
  3. Workflow-Without-Members Warnings: Triggers showConfirmModal alert on "Copy configuration" button press if workflows are selected without members to copy.
  4. State Persistence & Checkbox Synchronization: Added state pre-population via useEffect synchronizers in both CopyPolicySettingsSelectWorkspacesPage.tsx and CopyPolicySettingsSelectFeaturesPage.tsx connected to ONYXKEYS.COPY_POLICY_SETTINGS. This ensures selecting features/workspaces pre-populates properly when the user navigates backwards or forwards.

Fixed Issues

$ #88672
PROPOSAL: Internal

Tests

Setup

  1. Log in to NewDot as an admin of at least 3 workspaces (mix of Control and Collect, ideally with at least 2 sharing the same accounting connection and one connected to a different account or unconnected).
  2. From the Workspaces list, open the three-dot menu on a source workspace and tap Copy settings. The "Copy settings" RHP opens on the Select workspaces step.

Test 1 — Step 1 → 2 → 3 happy path

  1. Select workspaces step: Select one or more target workspaces and tap Next.
  2. Select features step: verify only feature rows that are active on the source workspace are shown (Overview, Members, Reports, Accounting, Categories, Tags, Taxes, Workflows, Rules, Distance rates, Per Diem, Invoices, Travel). Select a few features and tap Next.
  3. Confirm step: verify the page renders:
    • Header: Let's make sure everything looks right.
    • Subheader (rendered as HTML, the source workspace name is bold): We'll copy the following settings from {workspaceName} to the workspaces you've specified.
    • Settings row: comma-separated, translated, source-policy-style names of the selected features (e.g. Profile, Members). Long lists must wrap onto multiple lines (no truncation).
    • Workspaces row: comma-separated names of the selected targets. Long lists must wrap.
    • Footer button text: Copy settings.
  4. Tap Copy settings. The RHP dismisses and the copy action is dispatched.

Test 2 — Edit features from confirm

  1. Reach the Confirm step (Test 1, steps 1–3).
  2. Tap the Settings row → routed back to the Select features step. Verify the previously selected features are still checked.
  3. Change the selection (toggle rows on/off, optionally tap Select all).
  4. Tap Next. Verify you land back on the Confirm step and the Settings row reflects the updated selection.
  5. Tap the Settings row once more — the latest selection is still preserved.

Test 3 — Edit workspaces from confirm (re-validates features)

  1. Reach the Confirm step.
  2. Tap the Workspaces row → routed back to the Select workspaces step. Previously selected targets are still checked.
  3. Change the selection (e.g. add a target with a different/incompatible accounting connection) and tap Next.
  4. Verify you are routed to the Select features step (not directly back to Confirm). This is intentional — changing targets can flip which feature rows are selectable, so the user must re-validate.
  5. Verify rows that became incompatible are now greyed out with the alternate text:
    "You can only copy {part} if all workspaces use the same accounting system and company connection."
  6. Verify any previously-selected parts that are now incompatible (e.g. categories, tags, reports, taxes, or accounting itself) are silently dropped — they should not appear as ticked, and tapping Next must not surface them on the Confirm step.
  7. Tap Next → land on Confirm. The Settings row reflects the cleansed list; the Workspaces row reflects the new targets.

Test 4 — Closing the RHP discards the in-progress flow

  1. Open the flow and reach any step.
  2. Tap the X to close the RHP without copying.
  3. Re-open the flow from the same workspace's three-dot menu. Verify selections from the previous (uncommitted) attempt are NOT restored — the flow starts fresh on the Select workspaces step with nothing checked.

Test 5 — Workflows-without-members warning

  1. Create a source workspace with Workflows configured but only 1 member (yourself).
  2. Start Copy Settings flow → Select target workspaces → Next.
  3. On the Select features step, check Workflows but leave Members unchecked.
  4. Tap Next.
  5. Verify a confirmation modal appears warning that workflows may not apply correctly without members.
  6. Tap Continue to proceed to the Confirm step.
  7. Alternatively, tap Cancel to stay on Select features and adjust your selection.
  • Verify that no errors appear in the JS console

Offline tests

  1. Enter the Copy Settings flow.
  2. Go offline in your browser or simulator.
  3. Toggle features and workspaces and verify optimistic UI updates.

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 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
    • 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

Screenshot 2026-05-21 at 9 57 19 PM Screenshot 2026-05-21 at 9 59 14 PM
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Made with Cursor

@melvin-bot

melvin-bot Bot commented May 20, 2026

Copy link
Copy Markdown

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

@codecov

codecov Bot commented May 20, 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/CopyPolicySettingsUtils.ts 77.22% <100.00%> (+0.46%) ⬆️
src/pages/workspace/duplicate/utils.ts 0.00% <0.00%> (ø)
src/pages/workspace/WorkspacesListPage.tsx 72.53% <0.00%> (-0.26%) ⬇️
src/libs/actions/Policy/CopyPolicySettings.ts 82.24% <53.33%> (-4.72%) ⬇️
...ettings/CopyPolicySettingsSelectWorkspacesPage.tsx 0.00% <0.00%> (ø)
...ySettings/CopyPolicySettingsSelectFeaturesPage.tsx 0.00% <0.00%> (ø)
...pyPolicySettings/CopyPolicySettingsConfirmPage.tsx 0.00% <0.00%> (ø)
... and 38 files with indirect coverage changes

@fedirjh fedirjh changed the title [Bulk workspace edits] Page 3 (Double-check confirmation) [Bulk workspace edits] Add Copy Policy Settings Double-check confirmation page (step 3 of 3) May 20, 2026
fedirjh added 15 commits May 21, 2026 20:51
Refactor the selection logic to account for items that are effectively disabled, including those with a disabled checkbox. This ensures that only selectable items are added to the selected options and properly updates the disabled indexes.
…ySettingsSelectFeaturesPage

Updated the visibility and selection logic for features, ensuring that accounting compatibility is properly checked. Introduced a new method for handling accounting mismatch explanations and streamlined the alternate text retrieval for disabled features. This improves the user experience by providing clearer feedback on feature availability.
…bled features

When a feature row is disabled due to incompatible accounting
connections between source and target workspaces, display an
explanatory alternate text instead of the normal feature summary.
Precomputes eligible target policy IDs via useMemo so the per-item
menu render does a constant-time check instead of iterating all
policies. Hides the menu entry entirely when there are no valid
targets for the source workspace.
Introduced a new test suite for the BaseSelectionList component to validate the selection logic, specifically focusing on how disabled and selected items are handled in the allSelected calculation. The tests cover scenarios for fully selected, partially selected, and unselected states, ensuring accurate checkbox states reflect the selection status of items.
Introduced new utility functions to validate accounting connection compatibility between source and target policies. Updated the CopyPolicySettingsSelectFeaturesPage to utilize these functions for improved feature visibility and selection logic. Added unit tests to ensure the correctness of the new compatibility checks.
Updated the translation files for multiple languages to enhance the structure of the copy policy settings section. Introduced nested objects for select workspaces, select settings, and confirmation settings, providing clearer organization and descriptions for each step in the settings copying process. This change aims to improve user experience by making the interface more intuitive and user-friendly.
…ency

Refined the user interface for the copy policy settings pages by updating text labels and prompts to align with the new translation structure. This includes changes to the confirmation and selection pages, enhancing the overall user experience and ensuring consistency across the settings workflow.
…target change

Stale parts from a previous target set could remain in selectedFeatures and incorrectly
flip isAccountingSelected (force-locking coding parts) even when the accounting row was
itself disabled by Rule A. Extract isPartIncompatible (Rule A for accounting, Rule B for
coding parts) and filter it out of selectedAvailableFeatures so the effective selection
always reflects what's actually selectable for the current targets.
@fedirjh fedirjh requested review from francoisl and ishpaul777 May 21, 2026 22:09
@fedirjh fedirjh marked this pull request as ready for review May 21, 2026 22:09
@fedirjh fedirjh requested review from a team as code owners May 21, 2026 22:09
@melvin-bot melvin-bot Bot requested a review from flaviadefaria May 21, 2026 22:10
@shubham1206agra

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 there are no new alerts related to the canBeMissing param for useOnyx
  • I verified proper code patterns were followed (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
    • 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 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)
  • 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
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 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
  • xIf 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.
  • 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.
  • 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

Screen.Recording.2026-06-01.at.6.49.56.PM.mov
Screen.Recording.2026-06-01.at.11.56.01.PM.mov
Screen.Recording.2026-06-01.at.6.49.17.PM.mov

@ishpaul777 ishpaul777 requested a review from a team June 1, 2026 18:38
@yuwenmemon yuwenmemon merged commit 81de6f5 into Expensify:main Jun 1, 2026
38 of 39 checks passed
@melvin-bot melvin-bot Bot added the Emergency label Jun 1, 2026
@melvin-bot

melvin-bot Bot commented Jun 1, 2026

Copy link
Copy Markdown

@yuwenmemon looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

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

@yuwenmemon

Copy link
Copy Markdown
Contributor

Ah, crap, I didn't see that ESLint and TypeScript checks were failing. Since this was my boo boo I'll make a follow-up PR to fix.

@OSBotify

OSBotify commented Jun 1, 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.

@fedirjh fedirjh deleted the copy-policy-settings-page-3 branch June 1, 2026 19:43
@fedirjh

fedirjh commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

I think all tests already passed.

@yuwenmemon

Copy link
Copy Markdown
Contributor

Ah yep @fedirjh you are correct

@OSBotify

OSBotify commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/yuwenmemon in version: 9.3.91-0 🚀

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

Bundle Size Analysis (Sentry):

@mitarachim

Copy link
Copy Markdown

Deploy Blocker #92329 was identified to be related to this PR.

@mitarachim

Copy link
Copy Markdown

Deploy Blocker #92332 was identified to be related to this PR.

@jponikarchuk

Copy link
Copy Markdown

Deploy Blocker #92397 was identified to be related to this PR.

@OSBotify

OSBotify commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/yuwenmemon in version: 9.3.94-0 🚀

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

Bundle Size Analysis (Sentry):

@OSBotify

OSBotify commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 9.3.94-0 🚀

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

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.

9 participants