Skip to content

[Due for payment 2026-02-27] [$250] Feature: Ensure workspace merchant coding rules are copied to new workspace when duplicating workspaces #81364

Closed

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: @
Issue OwnerCurrent Issue Owner: @JmillsExpensify

Activity

  1. self-assigned this
    on Feb 4, 2026
  2. added
    Daily
    NewFeature
    on Feb 4, 2026
  3. melvin-bot commented on Feb 4, 2026

    @melvin-bot

    Triggered auto assignment to @dylanexpensify (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO. Remember to draft any necessary HelpDot updates by following the instructions here.

  4. added
    Weekly
    and removed
    Daily
    on Feb 4, 2026
  5. melvin-bot commented on Feb 4, 2026

    @melvin-bot

    Triggered auto assignment to Design team member for new feature review - @shawnborton (NewFeature)

  6. nyomanjyotisa commented on Feb 4, 2026

    @nyomanjyotisa
    Member

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Feature: Ensure workspace merchant coding rules are copied to new workspace when duplicating workspaces

    What is the root cause of that problem?

    The duplicate workspace feature doesn't include merchant coding rules in the list of features to copy. The items array in WorkspaceDuplicateSelectFeaturesForm doesn't include a checkbox for merchant rules, and the parts object passed to duplicateWorkspaceAction doesn't include codingRules.

    const items = useMemo(() => {
    const rules = getWorkspaceRules(policy, translate);
    const workflows = getWorkflowRules(policy, translate);
    const result = [
    {
    translation: translate('workspace.common.profile'),
    value: 'overview',
    alternateText: `${policy?.outputCurrency} ${translate('common.currency')}, ${formattedAddress}`,
    },
    totalMembers > 1
    ? {
    translation: translate('workspace.common.members'),
    value: 'members',
    alternateText: totalMembers ? `${totalMembers} ${translate('workspace.common.members').toLowerCase()}` : undefined,
    }
    : undefined,
    reportFields > 0
    ? {
    translation: translate('workspace.common.reports'),
    value: 'reports',
    alternateText: reportFields ? `${reportFields} ${translate('workspace.common.reportFields').toLowerCase()}` : undefined,
    }
    : undefined,
    connectedIntegration && connectedIntegration?.length > 0
    ? {
    translation: translate('workspace.common.accounting'),
    value: 'accounting',
    alternateText: connectedIntegration.map((connectionName) => CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]).join(', '),
    }
    : undefined,
    totalTags > 0
    ? {
    translation: translate('workspace.common.tags'),
    value: 'tags',
    alternateText: totalTags ? `${totalTags} ${translate('workspace.common.tags').toLowerCase()}` : undefined,
    }
    : undefined,
    categoriesCount > 0
    ? {
    translation: translate('workspace.common.categories'),
    value: 'categories',
    alternateText: categoriesCount ? `${categoriesCount} ${translate('workspace.duplicateWorkspace.categories').toLowerCase()}` : undefined,
    }
    : undefined,
    taxesLength > 0
    ? {
    translation: translate('workspace.common.taxes'),
    value: 'taxes',
    alternateText: taxesLength ? `${taxesLength} ${translate('workspace.common.taxes').toLowerCase()}` : undefined,
    }
    : undefined,
    workflows && workflows?.length > 0
    ? {
    translation: translate('workspace.common.workflows'),
    value: 'workflows',
    alternateText: workflows?.join(', '),
    }
    : undefined,
    rules && rules.length > 0 && !isCollect
    ? {
    translation: translate('workspace.common.rules'),
    value: 'rules',
    alternateText: rules.length
    ? `${rules.length} ${translate('workspace.common.workspace').toLowerCase()} ${translate('workspace.common.rules').toLowerCase()}: ${rules.join(', ')}`
    : undefined,
    }
    : undefined,
    ratesCount > 0 && policy?.areDistanceRatesEnabled
    ? {
    translation: translate('workspace.common.distanceRates'),
    value: 'distanceRates',
    alternateText: ratesCount ? `${ratesCount} ${translate('iou.rates').toLowerCase()}` : undefined,
    }
    : undefined,
    allRates > 0
    ? {
    translation: translate('workspace.common.perDiem'),
    value: 'perDiem',
    alternateText: allRates ? `${allRates} ${translate('workspace.common.perDiem').toLowerCase()}` : undefined,
    }
    : undefined,
    // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
    policy?.areInvoicesEnabled && ((bankAccountList && Object.keys(bankAccountList).length) || !!invoiceCompany)
    ? {
    translation: translate('workspace.common.invoices'),
    value: 'invoices',
    alternateText: bankAccountList ? `${Object.keys(bankAccountList).length} ${translate('common.bankAccounts').toLowerCase()}, ${invoiceCompany}` : invoiceCompany,
    }
    : undefined,
    policy?.isTravelEnabled
    ? {
    translation: translate('workspace.common.travel'),
    value: 'travel',
    }
    : undefined,
    ];
    return result.filter((item): item is NonNullable<typeof item> => !!item);
    }, [
    policy,
    translate,
    formattedAddress,
    totalMembers,
    reportFields,
    connectedIntegration,
    totalTags,
    categoriesCount,
    taxesLength,
    ratesCount,
    isCollect,
    allRates,
    bankAccountList,
    invoiceCompany,
    ]);

    parts: {
    people: selectedItems.includes('members'),
    reports: selectedItems.includes('reports'),
    connections: selectedItems.includes('accounting'),
    categories: selectedItems.includes('categories'),
    tags: selectedItems.includes('tags'),
    taxes: selectedItems.includes('taxes'),
    perDiem: selectedItems.includes('perDiem'),
    reimbursements: selectedItems.includes('invoices'),
    expenses: selectedItems.includes('rules'),
    distance: selectedItems.includes('distanceRates'),
    invoices: selectedItems.includes('invoices'),
    exportLayouts: selectedItems.includes('workflows'),
    overview: selectedItems.includes('overview'),
    travel: selectedItems.includes('travel'),
    },

    What changes do you think we should make in order to solve the problem?

    Add translation strings for merchant rules in the duplicateWorkspace section:

            duplicateWorkspace: {
                // ... existing keys ...
                merchantRules: 'Merchant rules',
                merchantRulesCount: ({count}: {count: number}) => `${count} merchant ${count === 1 ? 'rule' : 'rules'}`,
            },

    App/src/languages/en.ts

    Lines 5487 to 5499 in ae1c091

    duplicateWorkspace: {
    title: 'Name your new workspace',
    selectFeatures: 'Select features to copy',
    whichFeatures: 'Which features do you want to copy over to your new workspace?',
    confirmDuplicate: '\n\nDo you want to continue?',
    categories: 'categories and your auto-categorization rules',
    reimbursementAccount: 'reimbursement account',
    welcomeNote: 'Please start using my new workspace',
    delayedSubmission: 'delayed submission',
    confirmTitle: ({newWorkspaceName, totalMembers}: {newWorkspaceName?: string; totalMembers?: number}) =>
    `You’re about to create and share ${newWorkspaceName ?? ''} with ${totalMembers ?? 0} members from the original workspace.`,
    error: 'An error occurred while duplicating your new workspace. Please try again.',
    },

    Calculate the coding rules count after the other counts:

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

    const taxesLength = Object.keys(policy?.taxRates?.taxes ?? {}).length ?? 0;
    const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, {canBeMissing: true});
    const categoriesCount = Object.keys(policyCategories ?? {}).length;

    Add a merchant rules item to the items array after the rules item:

                rules && rules.length > 0 && !isCollect
                    ? {
                          translation: translate('workspace.common.rules'),
                          value: 'rules',
                          alternateText: rules.length
                              ? `${rules.length} ${translate('workspace.common.workspace').toLowerCase()} ${translate('workspace.common.rules').toLowerCase()}: ${rules.join(', ')}`
                              : undefined,
                      }
                    : undefined,
                codingRulesCount > 0 && !isCollect
                    ? {
                          translation: translate('workspace.duplicateWorkspace.merchantRules'),
                          value: 'codingRules',
                          alternateText: translate('workspace.duplicateWorkspace.merchantRulesCount', {count: codingRulesCount}),
                      }
                    : undefined,

    rules && rules.length > 0 && !isCollect
    ? {
    translation: translate('workspace.common.rules'),
    value: 'rules',
    alternateText: rules.length
    ? `${rules.length} ${translate('workspace.common.workspace').toLowerCase()} ${translate('workspace.common.rules').toLowerCase()}: ${rules.join(', ')}`
    : undefined,
    }
    : undefined,

    Add codingRules to the parts object in confirmDuplicate:

                parts: {
                    people: selectedItems.includes('members'),
                    reports: selectedItems.includes('reports'),
                    connections: selectedItems.includes('accounting'),
                    categories: selectedItems.includes('categories'),
                    tags: selectedItems.includes('tags'),
                    taxes: selectedItems.includes('taxes'),
                    perDiem: selectedItems.includes('perDiem'),
                    reimbursements: selectedItems.includes('invoices'),
                    expenses: selectedItems.includes('rules'),
                    distance: selectedItems.includes('distanceRates'),
                    invoices: selectedItems.includes('invoices'),
                    exportLayouts: selectedItems.includes('workflows'),
                    overview: selectedItems.includes('overview'),
                    travel: selectedItems.includes('travel'),
                    codingRules: selectedItems.includes('codingRules'),
                },

    parts: {
    people: selectedItems.includes('members'),
    reports: selectedItems.includes('reports'),
    connections: selectedItems.includes('accounting'),
    categories: selectedItems.includes('categories'),
    tags: selectedItems.includes('tags'),
    taxes: selectedItems.includes('taxes'),
    perDiem: selectedItems.includes('perDiem'),
    reimbursements: selectedItems.includes('invoices'),
    expenses: selectedItems.includes('rules'),
    distance: selectedItems.includes('distanceRates'),
    invoices: selectedItems.includes('invoices'),
    exportLayouts: selectedItems.includes('workflows'),
    overview: selectedItems.includes('overview'),
    travel: selectedItems.includes('travel'),
    },

    Add codingRulesCount to the items useMemo dependency array:

        }, [
            policy,
            translate,
            formattedAddress,
            totalMembers,
            reportFields,
            connectedIntegration,
            totalTags,
            categoriesCount,
            taxesLength,
            ratesCount,
            isCollect,
            allRates,
            bankAccountList,
            invoiceCompany,
            codingRulesCount,
        ]);

    }, [
    policy,
    translate,
    formattedAddress,
    totalMembers,
    reportFields,
    connectedIntegration,
    totalTags,
    categoriesCount,
    taxesLength,
    ratesCount,
    isCollect,
    allRates,
    bankAccountList,
    invoiceCompany,
    ]);

    Add isCodingRulesOptionSelected flag in buildDuplicatePolicyData:

        const isCodingRulesOptionSelected = parts?.codingRules;

    const isMemberOptionSelected = parts?.people;
    const isReportsOptionSelected = parts?.reports;
    const isConnectionsOptionSelected = parts?.connections;
    const isCategoriesOptionSelected = parts?.categories;
    const isTaxesOptionSelected = parts?.taxes;
    const isTagsOptionSelected = parts?.tags;
    const isInvoicesOptionSelected = parts?.invoices;
    const isDistanceRatesOptionSelected = parts?.distance;
    const isRulesOptionSelected = parts?.expenses;
    const isWorkflowsOptionSelected = parts?.exportLayouts;
    const isPerDiemOptionSelected = parts?.perDiem;
    const isOverviewOptionSelected = parts?.overview;
    const isTravelOptionSelected = parts?.travel;

    Conditionally exclude codingRules from the rules object in the optimistic data:

                    rules: policy?.rules
                        ? isCodingRulesOptionSelected
                            ? policy.rules
                            : {
                                  approvalRules: policy.rules.approvalRules,
                                  expenseRules: policy.rules.expenseRules,
                              }
                        : undefined,

    tax: isTaxesOptionSelected ? policy?.tax : undefined,
    employeeList: isMemberOptionSelected ? policy.employeeList : {[policy.owner]: policy?.employeeList?.[policy.owner]},
    id: targetPolicyID,
    name: policyName,
    fieldList: isReportsOptionSelected ? policy?.fieldList : undefined,
    connections: isConnectionsOptionSelected ? policy?.connections : undefined,
    customUnits: getCustomUnitsForDuplication(policy, isDistanceRatesOptionSelected, isPerDiemOptionSelected),
    taxRates: isTaxesOptionSelected ? policy?.taxRates : undefined,

    Note: This solution requires backend changes (DuplicatePolicy). The frontend changes only handle the UI and optimistic data

    What alternative solutions did you explore? (Optional)

    None

  7. 26 remaining items

  8. melvin-bot commented on Feb 21, 2026

    @melvin-bot

    ⚠️ Looks like this issue was linked to a Deploy Blocker here

    If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

    If a regression has occurred and you are the assigned CM follow the instructions here.

    If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

  9. added
    Daily
    and removed
    Weekly
    Daily
    on Feb 26, 2026
  10. JmillsExpensify commented on Mar 3, 2026

    @JmillsExpensify
    Contributor

    @situchan no payment is required on this one, right?

  11. situchan commented on Mar 4, 2026

    @situchan
    Contributor

    This was made External and contributor should be paid.

  12. JmillsExpensify commented on Mar 4, 2026

    @JmillsExpensify
    Contributor

    Payment summary: $250 @nyomanjyotisa via New Expensify.

  13. added
    Reviewing
    Weekly
    and removed
    Daily
    on Mar 19, 2026
  14. trjExpensify commented on May 29, 2026

    @trjExpensify
    Contributor

    approved $250 for @nyomanjyotisa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentExternalNewFeatureReviewingWeekly

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions