Add merchant rules option to workspace duplication#81514
Add merchant rules option to workspace duplication#81514JS00001 merged 10 commits intoExpensify:mainfrom
Conversation
|
Hey, I noticed you changed If you want to automatically generate translations for other locales, an Expensify employee will have to:
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 --helpTypically, you'd want to translate only what you changed by running |
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.
|
src/libs/actions/Policy/Policy.ts
Outdated
| approvalRules: policy?.rules?.approvalRules, | ||
| expenseRules: policy?.rules?.expenseRules, |
There was a problem hiding this comment.
This looks wrong to me. Shouldn't we add these two only if the "Rules" checkbox (which is different from the "Merchant rules" checkbox)
There was a problem hiding this comment.
@cead22 Do you think something like this is better?
rules:
isRulesOptionSelected || isCodingRulesOptionSelected
? {
approvalRules: isRulesOptionSelected ? policy?.rules?.approvalRules : undefined,
expenseRules: isRulesOptionSelected ? policy?.rules?.expenseRules : undefined,
codingRules: isCodingRulesOptionSelected ? policy?.rules?.codingRules : undefined,
}
: undefined,Additionally, since Merchant rules are only accessible through the Rules page, should we add a dependency in the UI where:
- Selecting
Merchant Rulesautomatically selectsRules - Deselecting
Rulesautomatically deselectsMerchant Rules
What do you think?
New-Expensify.mp4
There was a problem hiding this comment.
I don't think we should do that.
As for the code:
- If
isRulesOptionSelected || isCodingRulesOptionSelected- Create
ruleskey - If
isRulesOptionSelected, add approvalRules and expenseRules keys - If
isCodingRulesOptionSelected, add codingRules keys
- Create
There was a problem hiding this comment.
Got it, PR updated
|
Please merge main |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
|
@situchan merged with latest main |
JmillsExpensify
left a comment
There was a problem hiding this comment.
Part of an existing product initiative.
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-02-19.at.6.55.48.AM.movAndroid: mWeb ChromeiOS: HybridAppScreen.Recording.2026-02-18.at.9.12.38.PM.moviOS: mWeb SafariScreen.Recording.2026-02-19.at.6.58.36.AM.movMacOS: Chrome / SafariScreen.Recording.2026-02-18.at.9.04.02.PM.mov |
|
@nyomanjyotisa please merge main |
|
@situchan merged with the latest main |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 73ac904ed2
ℹ️ 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".
src/libs/actions/Policy/Policy.ts
Outdated
| isRulesOptionSelected || isCodingRulesOptionSelected | ||
| ? { | ||
| ...(isRulesOptionSelected && { |
There was a problem hiding this comment.
Enable Rules when copying merchant coding rules
This new branch allows codingRules to be duplicated even when expenses (the Rules feature toggle) is not selected, which produces a policy containing rules.codingRules while areRulesEnabled remains false. In that scenario, users cannot access or manage the copied merchant rules because the Rules page is gated by ARE_RULES_ENABLED in src/pages/workspace/rules/PolicyRulesPage.tsx (lines 35-38), so selecting only “Merchant rules” creates an inconsistent workspace state.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
@cead22 @JmillsExpensify @JS00001
When merchant rules are added and rule is disabled, should we still duplicate merchant rules while keeping rule disabled?
src/libs/actions/Policy/Policy.ts
Outdated
| ...(isRulesOptionSelected && { | ||
| approvalRules: policy?.rules?.approvalRules, | ||
| expenseRules: policy?.rules?.expenseRules, |
There was a problem hiding this comment.
Have you ever tested this? Seems not working for me
There was a problem hiding this comment.
What's the case when approvalRules, expenseRules data exists in rules?
There was a problem hiding this comment.
approvalRulesexists when the workspace has category or tag approvers (Workspace > Categories > Category Name > Approver)expenseRulesexists when categories have default tax rates configured (Workspace > Categories > Category Name > Default tax rate)
However the current DuplicatePolicy API does not copy approvalRules and expenseRules when the Rules checkbox is selected. Should these rules be duplicated when the Rules option is selected? If so, this would require backend changes as well
There was a problem hiding this comment.
I think this is out of scope. We're handling only merchant rules here.
There was a problem hiding this comment.
Oh that's my bad. I was confused because approvalRules and expenseRules live under the rules key, but you're right that we don't copy them. I thought isRulesOptionSelected referred to these rules, but that just for areRulesEnabled
I agree with leaving this out of scope. Let's focus only on merchant rules
There was a problem hiding this comment.
Got it, I've updated the PR
src/languages/en.ts
Outdated
| welcomeNote: 'Please start using my new workspace', | ||
| delayedSubmission: 'delayed submission', | ||
| merchantRules: 'Merchant rules', | ||
| merchantRulesCount: ({count}: {count: number}) => `${count} merchant ${count === 1 ? 'rule' : 'rules'}`, |
There was a problem hiding this comment.
This is against our translation pattern. Let's use one / other approach.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c41ee54a1
ℹ️ 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".
|
🚧 @JS00001 has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/JS00001 in version: 9.3.23-2 🚀
|
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.3.23-3 🚀
|
Explanation of Change
Add a new feature to ensure workspace merchant coding rules are copied to new workspace when duplicating workspaces
Fixed Issues
$ #81364
PROPOSAL: #81364 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
...menu on a workspacePR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android-Native.mp4
Android: mWeb Chrome
Android-mWeb.Chrome.mp4
iOS: Native
iOS-Native.mp4
iOS: mWeb Safari
iOS-mWeb.Safari.mp4
MacOS: Chrome / Safari
MacOS-Chrome.mp4