Repository navigation
Fix the expense default rule blockers from #104155 - #106054
Krishna2323 wants to merge 8 commits into
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>
…-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
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>
|
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 |
|
@MelvinBot review. |
| searchOnGoogle: ({merchant}: {merchant: string}) => `Search ${merchant} on Google`, | ||
| change: 'Change', | ||
| category: 'Category', | ||
| amount: 'Amount', |
There was a problem hiding this comment.
P1 — Complete the amount-history crash fix for non-English locales
Only English receives common.amount. For example, French still evaluates translations.common[key].toLowerCase() in src/languages/fr.ts:1995–1997, but its common object has no amount. Opening an expense with policyRulesModifiedFields.amount in French therefore still throws; all ten non-English locale modules lack this key. The new allowlist admits amount, so it does not prevent this crash.
Please add the amount label to every supported locale before landing, and cover amount-history rendering in a non-English regression test. English fallback cannot rescue this: the existing localized function is found and throws inside its own object lookup. This is an incomplete fix of the reported blocker, identified by static tracing; browser reproduction was blocked by unavailable Rules navigation.
|
🤖 Web test steps verification results: Verified setup only on dev NewDot web: created a workspace and changed its plan from Collect to Control. Rules navigation remained absent in the rendered Overview and failed a targeted visibility check, blocking both beta-on and beta-off rule testing; no source edits were made.
view run · no recording available |

Explanation of Change
Fixes the six frontend deploy blockers introduced by #104155.
This PR is branched off #105893, which relands #104155 behind the
expenseDefaultConditionsbeta. As a result, this diff contains only the fixes. Retarget tomainonce #105893 merges.Jack triaged the eleven blockers. Five are his:
The six below are frontend fixes, each in its own commit.
1. Crash when opening an expense repriced by a rule
Issue: #105805
iou.rulesModifiedFields.commonlooked up the field label usingtranslations.common[key].The backend sends
{amount: '$10.00'}, butcommondidn't have anamountkey. As a result,.toLowerCase()was called onundefined.A rule can also set the vendor, which has no label either. Unknown fields are now excluded from the message instead of being looked up.
2. Incorrect decimal formatting for currencies without cents
Issue: #105812
The Expense defaults table used
convertAmountToDisplayStringto format amounts. This is the tax rate formatter, which forces two to four decimal places and doesn't account for the currency's decimal configuration.The table now uses
convertToDisplayString, the same formatter used by the rule editor, so amounts are consistent in both places.3. Merchant could not be cleared
Issue: #105817
The merchant editor rejected empty values. This was correct when a merchant was the only condition a rule could have.
With the
expenseDefaultConditionsbeta, rules can also match on categories and tags, so clearing the merchant is necessary when an admin wants to replace one condition with another.The merchant field remains required when the beta is off. The rule editor also continues to reject rules without any matching conditions.
4. An amount of zero was dropped
Issue: #105819
Three separate places dropped zero amounts:
The editor closed without an error, but no amount was saved.
Zero is now treated as a valid default. An empty input still means the rule doesn't set an amount, which is different from setting it to zero.
5 and 6. Preview listed the wrong expenses
Issues:
There were two separate issues with the preview:
GetTransactionsMatchingCodingRule, which reads a merchant. This meant rules matching on categories returned no results. It now usesGetTransactionsMatchingRulewith the rule's scope and filters.Fixed Issues
PROPOSAL: N/A, deploy blocker fixes.
Tests
Precondition: A Control workspace with Rules, Categories, and Tags enabled, and the
expenseDefaultConditionsbeta enabled locally.Most of these changes are only reachable with the beta enabled. Beta-off checks are covered separately under QA Steps.
1. Crash when opening an expense repriced by a rule (#105805)
set the amount to "$10.00" ... via workspace rules.2. Amount formatting (#105812)
10.50, and save it.3. Clearing the merchant (#105817)
4. An amount of zero (#105819)
0and save.0rather than leaving the row empty.0is still there.0.5 and 6. Preview matches (#105829, #105828)
Offline Tests
QA Steps
The
expenseDefaultConditionsbeta is off on staging, so most of the changes above aren't reachable there.The following steps cover the functionality available without the beta, along with a regression pass on the existing merchant-only flow.
Precondition: A Control workspace with Rules and Categories enabled.
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