Repository navigation
Add increased distance violation display - #84453
Conversation
The modifiedDistance violation is generated by Auth when a distance expense is manually increased beyond the calculated route, but NewDot was not displaying it because the violation name was missing from the client-side translation system. Made-with: Cursor
|
@arosiclair Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
This comment has been minimized.
This comment has been minimized.
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.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e368ad4e40
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case 'modifiedDate': | ||
| return translate('violations.modifiedDate'); | ||
| case 'modifiedDistance': | ||
| return translate('violations.modifiedDistance'); |
There was a problem hiding this comment.
Add modifiedDistance translation across all locale files
This new branch now always calls translate('violations.modifiedDistance'), but this commit only adds that key in en.ts and es.ts; other locales (for example de, fr, ja, pt-BR, nl, pl, it, zh-hans) still lack it. When a non-English/Spanish user hits this violation, the app will fall back to a raw key in production and throw in development per src/libs/Localize/index.ts, so the violation text is still broken outside en/es.
Useful? React with 👍 / 👎.
The violation was being received via Onyx but not displayed because modifiedDistance was missing from the violationNameToField mapping in useViolations.ts. Also added formattedRouteDistance to the violation data type and updated translations to show the calculated route distance. Made-with: Cursor
This comment has been minimized.
This comment has been minimized.
…ction Map the violation to the waypoints field so it displays under the distance row. Read routeDistanceMeters from the transaction's customUnit instead of relying on data sent in the violation, and convert to the transaction's distance unit on the client side. Made-with: Cursor
The modifiedDistance violation text was inconsistent because getRBRMessages was not passing the transaction, so the route distance could not be resolved for the chat violation message. Made-with: Cursor
…odifiedDistance-violation
…rs, fix ESLint - Add modifiedDistance to de, fr, it, ja, nl, pl, pt-BR, zh-hans language files - Add ViolationsModifiedDistanceParams import to language files - Add routeDistanceMeters to DebugUtils pendingFields validation - Fix ChangeReceiptBillingAccountPage: remove setState in effect (derive effectiveSelected) Made-with: Cursor
This better describes the violation's purpose: it fires when a distance expense's quantity has been increased above the original calculated route, not for any arbitrary modification. Made-with: Cursor
This comment has been minimized.
This comment has been minimized.
🦜 Polyglot Parrot! 🦜Squawk! Looks like you added some shiny new English strings. Allow me to parrot them back to you in other tongues: View the translation diffdiff --git a/src/languages/de.ts b/src/languages/de.ts
index 9097aed0..4345901f 100644
--- a/src/languages/de.ts
+++ b/src/languages/de.ts
@@ -7910,7 +7910,7 @@ Fordern Sie Spesendetails wie Belege und Beschreibungen an, legen Sie Limits und
},
modifiedDate: 'Datum weicht vom gescannten Beleg ab',
increasedDistance: ({formattedRouteDistance}: ViolationsIncreasedDistanceParams) =>
- formattedRouteDistance ? `Distance exceeds the calculated route of ${formattedRouteDistance}` : 'Distance exceeds the calculated route',
+ formattedRouteDistance ? `Die Entfernung übersteigt die berechnete Route von ${formattedRouteDistance}` : 'Entfernung übersteigt die berechnete Route',
nonExpensiworksExpense: 'Nicht-Expensiworks-Ausgabe',
overAutoApprovalLimit: ({formattedLimit}: ViolationsOverLimitParams) => `Ausgabe überschreitet das Auto-Genehmigungslimit von ${formattedLimit}`,
overCategoryLimit: ({formattedLimit}: ViolationsOverCategoryLimitParams) => `Betrag über dem Kategorie-Limit von ${formattedLimit}/Person`,
diff --git a/src/languages/fr.ts b/src/languages/fr.ts
index 364b4410..b0f563d1 100644
--- a/src/languages/fr.ts
+++ b/src/languages/fr.ts
@@ -7933,7 +7933,7 @@ Rendez obligatoires des informations de dépense comme les reçus et les descrip
},
modifiedDate: 'La date diffère du reçu scanné',
increasedDistance: ({formattedRouteDistance}: ViolationsIncreasedDistanceParams) =>
- formattedRouteDistance ? `Distance exceeds the calculated route of ${formattedRouteDistance}` : 'Distance exceeds the calculated route',
+ formattedRouteDistance ? `La distance dépasse l’itinéraire calculé de ${formattedRouteDistance}` : 'La distance dépasse l’itinéraire calculé',
nonExpensiworksExpense: 'Dépense non Expensiworks',
overAutoApprovalLimit: ({formattedLimit}: ViolationsOverLimitParams) => `La dépense dépasse la limite d’auto-approbation de ${formattedLimit}`,
overCategoryLimit: ({formattedLimit}: ViolationsOverCategoryLimitParams) => `Montant dépassant la limite de catégorie de ${formattedLimit}/personne`,
diff --git a/src/languages/it.ts b/src/languages/it.ts
index aeeb9cb0..b10f367e 100644
--- a/src/languages/it.ts
+++ b/src/languages/it.ts
@@ -7897,7 +7897,7 @@ Richiedi dettagli sulle spese come ricevute e descrizioni, imposta limiti e valo
},
modifiedDate: 'Data diversa dalla ricevuta scansionata',
increasedDistance: ({formattedRouteDistance}: ViolationsIncreasedDistanceParams) =>
- formattedRouteDistance ? `Distance exceeds the calculated route of ${formattedRouteDistance}` : 'Distance exceeds the calculated route',
+ formattedRouteDistance ? `La distanza supera il percorso calcolato di ${formattedRouteDistance}` : 'La distanza supera il percorso calcolato',
nonExpensiworksExpense: 'Spesa non-Expensiworks',
overAutoApprovalLimit: ({formattedLimit}: ViolationsOverLimitParams) => `La spesa supera il limite di approvazione automatica di ${formattedLimit}`,
overCategoryLimit: ({formattedLimit}: ViolationsOverCategoryLimitParams) => `Importo superiore al limite di categoria di ${formattedLimit}/persona`,
diff --git a/src/languages/ja.ts b/src/languages/ja.ts
index c451c8c5..173a14fb 100644
--- a/src/languages/ja.ts
+++ b/src/languages/ja.ts
@@ -7809,7 +7809,7 @@ ${reportName}
},
modifiedDate: '日付がスキャンしたレシートと異なります',
increasedDistance: ({formattedRouteDistance}: ViolationsIncreasedDistanceParams) =>
- formattedRouteDistance ? `Distance exceeds the calculated route of ${formattedRouteDistance}` : 'Distance exceeds the calculated route',
+ formattedRouteDistance ? `距離が計算されたルート距離(${formattedRouteDistance})を超えています` : '距離が計算されたルートを超えています',
nonExpensiworksExpense: 'Expensiworks 以外の経費',
overAutoApprovalLimit: ({formattedLimit}: ViolationsOverLimitParams) => `経費が自動承認限度額 ${formattedLimit} を超えています`,
overCategoryLimit: ({formattedLimit}: ViolationsOverCategoryLimitParams) => `1人あたりのカテゴリ上限 ${formattedLimit} を超えた金額`,
diff --git a/src/languages/nl.ts b/src/languages/nl.ts
index a7c73c16..33381020 100644
--- a/src/languages/nl.ts
+++ b/src/languages/nl.ts
@@ -7875,7 +7875,7 @@ Vereis onkostendetails zoals bonnen en beschrijvingen, stel limieten en standaar
},
modifiedDate: 'Datum wijkt af van gescande bon',
increasedDistance: ({formattedRouteDistance}: ViolationsIncreasedDistanceParams) =>
- formattedRouteDistance ? `Distance exceeds the calculated route of ${formattedRouteDistance}` : 'Distance exceeds the calculated route',
+ formattedRouteDistance ? `Afstand overschrijdt de berekende route van ${formattedRouteDistance}` : 'Afstand overschrijdt de berekende route',
nonExpensiworksExpense: 'Niet-Expensiworks-uitgave',
overAutoApprovalLimit: ({formattedLimit}: ViolationsOverLimitParams) => `Kosten overschrijden de automatische goedkeuringslimiet van ${formattedLimit}`,
overCategoryLimit: ({formattedLimit}: ViolationsOverCategoryLimitParams) => `Bedrag boven de categorielimiet van ${formattedLimit} per persoon`,
diff --git a/src/languages/pl.ts b/src/languages/pl.ts
index 60878222..27b43c7c 100644
--- a/src/languages/pl.ts
+++ b/src/languages/pl.ts
@@ -7863,7 +7863,7 @@ Wymagaj szczegółów wydatków, takich jak paragony i opisy, ustawiaj limity i
},
modifiedDate: 'Data różni się od zeskanowanego paragonu',
increasedDistance: ({formattedRouteDistance}: ViolationsIncreasedDistanceParams) =>
- formattedRouteDistance ? `Distance exceeds the calculated route of ${formattedRouteDistance}` : 'Distance exceeds the calculated route',
+ formattedRouteDistance ? `Dystans przekracza obliczoną trasę ${formattedRouteDistance}` : 'Dystans przekracza obliczoną trasę',
nonExpensiworksExpense: 'Wydatek spoza Expensiworks',
overAutoApprovalLimit: ({formattedLimit}: ViolationsOverLimitParams) => `Wydatek przekracza automatyczny limit zatwierdzania w wysokości ${formattedLimit}`,
overCategoryLimit: ({formattedLimit}: ViolationsOverCategoryLimitParams) => `Kwota przekracza limit kategorii w wysokości ${formattedLimit}/osobę`,
diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts
index a8b71517..6d6a9125 100644
--- a/src/languages/pt-BR.ts
+++ b/src/languages/pt-BR.ts
@@ -7867,7 +7867,7 @@ Exija dados de despesas como recibos e descrições, defina limites e padrões e
},
modifiedDate: 'Data diferente do recibo digitalizado',
increasedDistance: ({formattedRouteDistance}: ViolationsIncreasedDistanceParams) =>
- formattedRouteDistance ? `Distance exceeds the calculated route of ${formattedRouteDistance}` : 'Distance exceeds the calculated route',
+ formattedRouteDistance ? `A distância excede a rota calculada de ${formattedRouteDistance}` : 'A distância excede a rota calculada',
nonExpensiworksExpense: 'Despesa fora do Expensiworks',
overAutoApprovalLimit: ({formattedLimit}: ViolationsOverLimitParams) => `Despesa excede o limite de aprovação automática de ${formattedLimit}`,
overCategoryLimit: ({formattedLimit}: ViolationsOverCategoryLimitParams) => `Valor acima do limite de categoria de ${formattedLimit}/pessoa`,
diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts
index 0ec175a6..a0f896a4 100644
--- a/src/languages/zh-hans.ts
+++ b/src/languages/zh-hans.ts
@@ -7674,7 +7674,7 @@ ${reportName}
},
modifiedDate: '日期与已扫描收据不符',
increasedDistance: ({formattedRouteDistance}: ViolationsIncreasedDistanceParams) =>
- formattedRouteDistance ? `Distance exceeds the calculated route of ${formattedRouteDistance}` : 'Distance exceeds the calculated route',
+ formattedRouteDistance ? `距离超过计算出的路线 ${formattedRouteDistance}` : '距离超过计算的路线',
nonExpensiworksExpense: '非 Expensiworks 报销',
overAutoApprovalLimit: ({formattedLimit}: ViolationsOverLimitParams) => `报销金额超出自动审批上限 ${formattedLimit}`,
overCategoryLimit: ({formattedLimit}: ViolationsOverCategoryLimitParams) => `金额超出每人 ${formattedLimit} 的类别限额`,
Note You can apply these changes to your branch by copying the patch to your clipboard, then running |
…rimitives getViolationTranslation only accesses transaction.comment.customUnit for the increasedDistance violation. Passing the entire Transaction object forced callers to include it in useMemo dependency arrays, causing unnecessary recomputation whenever any unrelated field changed. Made-with: Cursor
…hould be Unit Changed routeDistanceMeters from number | string to just number in Transaction.ts since the backend always returns a numeric value. Updated distanceUnit parameter in getViolationTranslation from string to Unit type to match the DistanceRequestUtils.getDistanceForDisplayLabel signature. Made-with: Cursor
…odifiedDistance-violation Made-with: Cursor # Conflicts: # Mobile-Expensify # src/languages/de.ts # src/languages/en.ts # src/languages/fr.ts # src/languages/it.ts # src/languages/ja.ts # src/languages/nl.ts # src/languages/params.ts # src/languages/pl.ts # src/languages/pt-BR.ts # src/languages/zh-hans.ts
…anslate Replace the custom enTranslate helper and eslint-disable block with IntlStore spies that load real English translations, allowing the standard translateLocal to resolve actual English strings. Made-with: Cursor
The --experimental-vm-modules flag in npm test enables dynamic imports, so IntlStore.load(CONST.LOCALES.EN) works correctly. Remove the en, flattenObject imports and IntlStore spy setup in favor of the simpler IntlStore.load pattern matching the reviewer's suggestion. Made-with: Cursor
|
@situchan thank you for helping to clean that up. Changes have been made. |
|
@carlosmiceli Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
@neil-marcellini looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
🚧 @neil-marcellini 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/neil-marcellini in version: 9.3.50-0 🚀
Bundle Size Analysis (Sentry): |
|
I have failed to help you. I let you down and for that I am sorry. Please try again later. This may be due to a Claude outage (check here). Failure details: https://github.com/Expensify/Expensify/actions/runs/23647042165 |
|
Hi @neil-marcellini. Can this PR be implemented on the native apps, or will testing on the web be enough? |
|
For OD, web is enough. |
|
@situchan, how can we create distance expenses using the map? In the hybrid app, that option is not showing WhatsApp.Video.2026-03-27.at.3.32.18.PM.mp4 |
Please do this in OD web. Just test violation visibility in native apps. |
|
@situchan When we run the command const policy = Policy.getActive(); policy.policy.isPolicyExpenseChatEnabled = false; policy.save(); from this test case, the expenses are not shown in the New hybrid app for the account. 2b6a6cc7bf063f340ea3574d0eed9ad0.mp4 |
That's expected. |
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.3.50-8 🚀
|
Explanation of Change
Auth generates an
increasedDistanceviolation when a user manually increases a distance expense beyond the calculated route. OldDot already displayed it, but NewDot silently ignored it.This PR adds NewDot support by registering the violation in
CONST.VIOLATIONS, mapping it to thewaypointsfield inuseViolations, adding a translation case inViolationsUtils.getViolationTranslation()that formats the original route distance, and passingrouteDistanceMeters/distanceUnitfrom the transaction'scustomUnitthrough to all violation display sites (MoneyRequestView,MoneyRequestReceiptView,TransactionPreviewContent,ViolationMessages).Related Issues
https://github.com/Expensify/Expensify/issues/605320
Tests
OldDot and NewDot - increase distance after creation
2026-03-10_16-44-15.mp4
OldDot only - increase distance after creation
2026-03-12_15-21-32.mp4
OldDot and NewDot - increase distance before creation
2026-03-11_13-30-52.mp4
OldDot only - increase distance before creation
2026-03-12_15-25-16.mp4
OldDot only - changing distance unit
Note: Updating distance expenses between OldDot and NewDot is currently a bit buggy, so we only test on OldDot. For example see this internal issue OldDot distance edit breaks future NewDot waypoint updates.
2026-03-12_16-58-17.mp4
Offline tests
N/A - Violations are fetched from the server; offline behavior is unchanged.
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand 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
See the tests above on mac Chrome. I only tested on one platform because the changes should be platform independent. C+ will test all platforms.
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Made with Cursor