Repository navigation
Conversation
…2323/issue-102277-expense-defaults" This reverts commit 9f34259, restoring the amount and tag conditions on expense default rules exactly as they were. The resulting tree is byte for byte identical to main at 90b4be4, so this commit carries no behavior change of its own. The beta gate that keeps the feature off follows in the next commit. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
A rule could match on a tag and set an amount, and could match on a category alone rather than needing a merchant. The engine does not apply those rules yet, so an admin could save one that silently never fires, which is where the deploy blockers on the release came from. Off the beta the editor behaves as it did before those conditions existed: a merchant is the only thing a rule may match on, and the tag and amount rows are hidden. A rule that already carries a tag or an amount keeps its row, so a value the rule still applies is not saved out of sight. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
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.
|
…-104155-expense-defaults-beta Signed-off-by: krishna2323 <belivethatkg@gmail.com> # Conflicts: # config/oxlint/oxlint.seatbelt.tsv # tests/actions/IOU/MoneyRequestSettersTest.ts # tests/actions/IOUTest/SplitTest.ts # tests/actions/IOUTest/UpdateMoneyRequestTest.ts
|
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 bun ./scripts/generateTranslations.ts --helpTypically, you'd want to translate only what you changed by running |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@MelvinBot review |
|
🤖 Web test steps verification results: ❌ fail On dev NewDot web, the category-tax regression reproduces: saving a category-scoped, non-default tax rule incorrectly requires another condition. Original steps 1–7 pass; expense creation and Preview filtering remain unverified.
|
…-104155-expense-defaults-beta Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Requiring a merchant off the beta blocked the rule the category settings page creates, which has matched on a category alone since before expense defaults could match on anything else. An admin picking a rate for a category was told to add a condition, and adding a merchant narrows the rule rather than fixing it. Off the beta a rule may now match on a merchant, or on a category when all it sets is a tax. The client reads a category tax default itself when an expense is categorized, so that one applies whatever the engine matches on. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
|
@situchan ready for review |
Opening an expense a rule changed builds the "via workspace rules" message from policyRulesModifiedFields. The message looks the field label up in translations.common by its key, and common had no amount, so the lookup returned undefined and toLowerCase threw. A rule can set the vendor too, whose key has no label either, so an unknown field is now dropped from the message rather than looked up. Fixes Expensify#105805 Signed-off-by: krishna2323 <belivethatkg@gmail.com>
The Expense defaults table built the amount with convertAmountToDisplayString, which is the tax rate formatter. It always shows two to four decimals and never reads how many the currency has, so a rule still read "10.50" on a workspace switched to a currency with no subunit, while the rule editor read "11". The table now uses the same convertToDisplayString the editor does, so a rule reads the same in both places. Fixes Expensify#105812 Signed-off-by: krishna2323 <belivethatkg@gmail.com>
The merchant editor refused an empty value, which was right while a merchant was the only thing an expense default rule could match on. A rule can now match on a category or a tag instead, so an admin who wanted to swap one condition for another had no way to remove the merchant. The field is still required off the expense default conditions beta, where a merchant remains the only condition. The rule editor keeps refusing a rule that matches on nothing either way. Fixes Expensify#105817 Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Zero was dropped in three places. The editor saved an empty string for it, the rule builder returned no action for it, and reading a rule back refused any amount that was not negative, which a zero is not. Together they let the editor close with no error and no amount saved. Zero is now a default like any other, so an admin can write a rule that zeroes an expense out. An empty input still means the rule sets no amount at all, which is a different thing. This reverses the decision that zero is not a default, which the amount tests stated. QA and the issue both read the silent close as a bug rather than as the field refusing a value. Fixes Expensify#105819 Signed-off-by: krishna2323 <belivethatkg@gmail.com>
The preview asked GetTransactionsMatchingCodingRule, which reads a merchant, so a rule matching on a category listed none of the expenses it would apply to. It now asks GetTransactionsMatchingRule with the rule's scope and its filters, which is the command the rules engine answers for a rule of any shape. The previous answer is also dropped before asking again. The results are a collection keyed by transaction, so a preview that matched fewer expenses than the last one left the ones it no longer matched on screen. Fixes Expensify#105829 Fixes Expensify#105828 Signed-off-by: krishna2323 <belivethatkg@gmail.com>
|
@MelvinBot review Since your last run, there have been 6 new commits. The [P2] category-tax regression you found has been fixed, and the five fixes from #106054 are now included, one per commit. Please focus on the areas that were unverified last time, with the beta disabled:
The tag, amount, and category-only paths require the |
The preview built a fresh filter tree on every render and keyed its request on that object, so the request went out again every time the page rendered. Clearing the previous answer before each request made every answer render the page again, which asked again, and the spinner never stopped. The request is now keyed on what the tree holds rather than on its identity, and the action takes the filters already serialized, which is what the command sends. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
|
🤖 Web test steps verification results: Verified category-tax rules, manual expense creation, merchant-rule summary, report navigation, and the persisted description default on dev NewDot web. Both merchant previews remained loading; beta-disabled status is unverified.
|
…-104155-expense-defaults-beta Signed-off-by: krishna2323 <belivethatkg@gmail.com>
A transaction's taxAmount is stored in the smallest currency units, but it was passed through convertToBackendAmount alongside the freshly calculated amount, which is in major units. A moved track expense keeping $5.00 of tax was written back as $500.00. Two tests asserted the inflated value, so they are corrected too. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Clearing a category falls back to the workspace default tax, and that fallback is gated on the policy having a category tax rule, which is read from the rules collection. Clearing before GetRules lands left the previous category's tax in place, and the replay skipped it. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
The rules engine applies every matching rule in turn and each one writes over what the last left, so where two rules set a tax on the same category the newest is the rate the expense ends up with. Stopping at the first match predicted a rate the server then replaced. A later rule that matches but sets no tax leaves the earlier rate alone, since the engine writes only the fields a rule sets. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
Thanks, both confirmed and fixed, along with precedence. 1. Tax amount inflated. 2. Cleared split category. 3. Precedence. Switched to the last matching rule, so the newest rule's tax wins. A later rule that matches but sets no tax leaves the earlier rate alone, since the engine only writes the fields a rule sets. One thing this contradicts: the duplicate rule prompt on main says "Your existing rule for X will take priority over this one." Should that copy change to say the new rule wins? 4. Member access. This one needs your call. |
The hooks this PR adds below it split the block React Compiler used to cache the category computation in, which left getDistanceRateCustomUnit running on every render of the confirmation page. Reading the rate into its own value gives the compiler an object to key the guard on. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
A category tax default migrated from policy.rules.expenseRules carries a priority of 40000 while one written by the merchant rule editor carries 10000, so the backend applies the migrated rule last and it writes over the newer one. Sorting on age alone picked the newer rule's rate, which the server then replaced. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
A failed GetRules settles the wait with no rules, so the expense is given the workspace default. When a reconnect landed the rules, that default differed from the category rule's rate and so read as a rate the user had picked, which held it in place and left the rule unapplied. Tracking the default the hook handed over tells the two apart. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…ory rule The manual branch of getCategoryTaxDetails already does this, so a category with no rule does not carry the rate its predecessor set. The distance branch returned nothing instead, which left the previous category's tax on the draft. getDistanceRateTaxUpdates has already charged the tax at the rate's own default, so the fallback is the value we were discarding. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
A failed GetRules settles the wait, so a category picked in that window resolved against an empty collection and was then recorded as resolved. The reconnect that landed the rules hit the equality check and skipped, leaving the previous category's tax on the split. useRulesPrefetch now reports whether the collection actually arrived, so that pick is replayed once it has. The category the screen opened with is still left alone. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
A rule migrated from the old policy rules carries a higher priority than anything the merchant rule editor creates, and priority decides which of two matching rules the engine applies last. Saving the editor's priority over it changed which tax an expense ended up with on an edit that never touched the tax. Mirrors what this function already does for created. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
The retry replays the category to resolve it against rules the first pass never had, which also rewrote a tax the user had chosen in between. A resolution with no rules to read leaves the draft's tax alone, so recording the tax going in gives the retry something to recognise its own work by, and a draft carrying anything else is left as it is. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
…-104155-expense-defaults-beta Signed-off-by: krishna2323 <belivethatkg@gmail.com> # Conflicts: # config/oxlint/oxlint.seatbelt.tsv # src/pages/workspace/categories/CategorySettingsPage.tsx # src/pages/workspace/rules/MerchantRules/ExpenseDefaultTypePage.tsx # src/pages/workspace/rules/RulesNewPage.tsx
|
🚧 JS00001 has triggered a test Expensify/App build. You can view the workflow run here. |
This comment has been minimized.
This comment has been minimized.
|
Requested adhoc testing: https://expensify.slack.com/archives/C09V78U42D8/p1794579166473439 |
…beta One conflict in TransactionUtils/tax.ts, an import line that both sides grew. Main added isTaxCodeCustomized for getTaxCodeForDisplay, this branch added the expense default rule helpers. Keep both. Signed-off-by: krishna2323 <belivethatkg@gmail.com>
|
🚧 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. |
|
Regression was completed |
|
🚀 Deployed to staging by https://github.com/JS00001 in version: 9.5.40-0 🚀
|
|
Help site update needed — this releases tag/category-only conditions and amount defaults without a beta. The existing setup step incorrectly tells readers to choose between Merchant and Category. No docs PR created: live UI verification was blocked by a Control-plan upgrade prompt, so I couldn't confirm the replacement instructions and exact labels. |





Explanation of Change
Relands #104155 after it was reverted in #105888, and fixes the frontend deploy blockers it caused.
#104155 added three things to expense default rules:
Eleven deploy blockers followed, so the whole PR was reverted.
No beta
This PR first relanded the feature behind
CONST.BETAS.EXPENSE_DEFAULT_CONDITIONS. That beta is gone again, because @situchan and @JS00001 were right that it covered too little to be worth having.The gate only reached the save validator, the Tag condition row and the Amount default row. Everything else the editor offers was left ungated, so off the beta an admin could fill in a category condition and a reimbursable default and then be told to add a condition, because the validator counted neither. Covering the rest would have meant gating most of the editor. The feature ships whole instead, and QA runs the full flow on an ad-hoc build before this merges.
Nothing here needs a server-side beta to be created.
Commits
One issue per commit, so they read on their own. In order:
90b4be42da4, so this commit carries no behavior change of its own.Commits 2, 3 and 13 are reviewable as a pair of opposites. If you are reading commit by commit and want to skip the detour, the net of the three is that no beta exists and the merchant field can always be cleared.
The blocker fixes
Jack triaged the eleven blockers. Five are not ours, listed under Fixed Issues below. The six here are.
Crash opening an expense a rule repriced (#105805).
iou.rulesModifiedFields.commonlooked the field label up astranslations.common[key]. The backend sends{amount: '$10.00'}andcommonhad noamount, so.toLowerCase()ran onundefined. A rule can also set the vendor, whose key has no label either, so an unknown field is now left out of the message rather than looked up.Note
This is the reason the fixes are in this PR rather than a follow-up. A rule created while #104155 was on staging still exists, the backend still applies it, and the report still crashes.
Cents on a currency that has none (#105812). The Expense defaults table formatted the amount with
convertAmountToDisplayString, which is the tax rate formatter: it forces two to four decimals and never reads the currency's. The table now uses the sameconvertToDisplayStringthe rule editor does, so a rule reads the same in both places.Merchant could not be cleared (#105817). The merchant editor rejected an empty value, which was right while a merchant was the only condition a rule could carry. A rule can now match on a category or a tag, so clearing the merchant is how an admin swaps one condition for another. The rule editor still refuses a rule that matches on nothing.
An amount of zero was dropped (#105819). Three places dropped it independently: the editor saved an empty string, the rule builder returned no action, and reading a rule back refused any amount that was not negative. The editor closed with no error and no amount saved. Zero is now a default like any other. An empty input still means the rule sets no amount, which is a different thing.
Preview listed the wrong expenses (#105828, #105829). The preview asked a command that only read the merchant leaf of the filter tree, so a category or tag rule matched nothing. The answer is also keyed by transaction in Onyx, so a preview matching fewer expenses than the last one kept showing the ones it no longer matched. The command now reads the whole tree, and the previous answer is cleared before the new one is asked for.
The two bugs found in review
Categorizing a tracked expense did not apply the category's tax rate. Reported by @situchan. Before #104155, picking a category wrote the rate its rule asked for straight onto the draft, from
setMoneyRequestCategory, reading the rules off the policy. The rules moved into their own collection, so that write was dropped andTaxControllerwas left as the only writer.TaxControllerholds everything back while an expense is moving off a track expense, so nothing applied the rule.That guard protects the rate the expense arrived with, so it stays for the workspace default, which is a rate nobody chose for this expense. A category rule is a rate the destination's admin chose, so it applies now, and the tax amount is charged again at it rather than kept from the rate it replaced.
The category settings rule editor offered defaults it then refused. Also reported by @situchan, and caused by the beta gate. Fixed by removing it.
Fixed Issues
$ #102277
$ #105805
$ #105812
$ #105817
$ #105819
$ #105828
$ #105829
Not fixed here, per Jack's triage, and left off the list above: #105811 (negative amounts are intentional), #105822 and #105855 (intended current behavior), #105859 and #105862 (backend).
PROPOSAL: N/A, reland of a reverted PR
Tests
Precondition: a Control workspace with Rules, Categories, Tags and Taxes enabled.
Conditions and defaults
Category settings entry point
Category tax defaults are applied
The amount
set the amount to "..." via workspace rules.Preview
Offline tests
QA Steps
Precondition: a Control workspace with Rules, Categories, Tags and Taxes enabled. No beta is needed.
PR 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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Monosnap.screencast.2026-11-05.17-14-44.mp4