Skip to content

[$250] Feature: Ensure workspace merchant coding rules are copied to new workspace when duplicating workspaces #81364

@cead22

Description

@cead22

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Expected Result:

  • Go to workspaces page
  • Press the ... menu on a workspace
  • Press Duplicate Workspace
  • Enter the workspace name
  • Press Next
  • On this screen there should be a new checkbox to copy "Merchant Rules" under the checkbox for "Rules"
  • The subtitle of that checkbox should be "N merchant rules" where N is the number of merchant coding rules
  • Press Continue
  • Press Proceed on the dialog
  • Ensure the workspace was duplicated
    • If the Merchant Rules checkbox was selected, and there are merchant coding rules in the original workspace, the merchant rules should be present in the new workspace
    • If the Merchant Rules checkbox was selected, and there are no merchant coding rules in the original workspace, or if the Merchant Rules checkbox was not selected, there should be no merchant coding rules in the new workspace

Here are the steps Cursor suggested - note that this will require backend changes for it to work

  1. Add translation strings
    In src/languages/en.ts, add to the duplicateWorkspace section (around line 5485):
duplicateWorkspace: {
    // ... existing keys ...
    merchantRules: 'Merchant rules',
    merchantRulesCount: ({count}: {count: number}) => `${count} merchant ${count === 1 ? 'rule' : 'rules'}`,
},

Add corresponding translations in all other language files (es.ts, fr.ts, de.ts, it.ts, ja.ts, nl.ts, pl.ts, pt-BR.ts, zh-hans.ts).

  1. Update WorkspaceDuplicateSelectFeaturesForm.tsx
    In src/pages/workspace/duplicate/WorkspaceDuplicateSelectFeaturesForm.tsx
    a) Import isEmptyObject if not already imported:
import {isEmptyObject} from '@src/types/utils/EmptyObject';

b) Add a variable to count coding rules (around line 56):

const codingRulesCount = Object.keys(policy?.rules?.codingRules ?? {}).length;

c) Add a new item to the items array (around line 136, after the rules item):

codingRulesCount > 0 && !isCollect
    ? {
          translation: translate('workspace.duplicateWorkspace.merchantRules'),
          value: 'codingRules',
          alternateText: translate('workspace.duplicateWorkspace.merchantRulesCount', {count: codingRulesCount}),
      }
    : undefined,

d) Update the parts object in confirmDuplicate (around line 223) to add the new key:

parts: {
    // ... existing parts ...
    codingRules: selectedItems.includes('codingRules'),
},

e) Add codingRulesCount to the dependencies array of items useMemo (around line 186).

Screenshots/Videos

Image

cc @JmillsExpensify @JS00001 @luacmartins

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @
Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~022019136503061610055
  • Upwork Job ID: 2019136503061610055
  • Last Price Increase: 2026-02-04
  • Automatic offers:
    • situchan | Reviewer | 110349053
Issue OwnerCurrent Issue Owner: @

Metadata

Metadata

Labels

ExternalAdded to denote the issue can be worked on by a contributorNewFeatureSomething to build that is a new item.ReviewingHas a PR in reviewWeeklyKSv2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions