Skip to content

Add frontend validation for distance expense amounts exceeding backend limit (v2)#83170

Merged
neil-marcellini merged 32 commits intomainfrom
neil-distanceAmountValidation-v2
Mar 2, 2026
Merged

Add frontend validation for distance expense amounts exceeding backend limit (v2)#83170
neil-marcellini merged 32 commits intomainfrom
neil-distanceAmountValidation-v2

Conversation

@neil-marcellini
Copy link
Contributor

@neil-marcellini neil-marcellini commented Feb 22, 2026

(Neil's AI agent)

This is a clean v2 of #82971, with duplicate commits removed.


Explanation of Change

Extreme odometer or manual distance values can produce expense amounts that exceed the backend WAF's 12-digit limit (999,999,999,999 cents). When this happens, the WAF silently strips the amount parameter from the API request, causing a null amount exception during Transaction_Merge (ExpException at api.php:1686).

This PR adds client-side validation to prevent users from submitting distance expenses with amounts that would exceed the backend limit.

Amount validation (distance × rate):

  • Added MAX_SAFE_AMOUNT: 999999999999 constant to CONST.IOU matching the backend WAF regex limit
  • Added isDistanceAmountWithinLimit(distance, rate) utility in DistanceRequestUtils
  • Added validation to the Odometer page, Manual distance page, Rate edit page, and MoneyRequestConfirmationList
  • Context-specific error messages: distance pages say "Reduce the distance", rate page says "Lower the rate", confirmation page says both

Odometer reading limits:

  • Added ODOMETER_MAX_VALUE: 9999999.9 — max reading of 9,999,999.9 to support commercial vehicles
  • Odometer inputs silently reject keystrokes that would exceed the max value or add more than 1 decimal place
  • Submit-time validation as a safety net for edge cases (paste, pre-populated legacy values)

Locale-aware input parsing:

  • Odometer readings are parsed using replaceAllDigits + fromLocaleDigit so European formats (e.g., German 1.234.567,9) are handled correctly
  • Error messages use numberFormat to display the max value in the user's locale

Rate edit UX:

  • When selecting a rate that would cause the amount to exceed the limit, the error message displays and the invalid rate stays visually selected (via pendingRateID state)
  • Selecting a valid rate clears the error and navigates back
  • Hitting back without fixing preserves the previously stored rate

Localization:

  • All error messages localized in all 10 language files
  • odometerReadingTooLarge uses a function with locale-formatted max value instead of hardcoded numbers

Fixed Issues

$ https://github.com/Expensify/Expensify/issues/601062

Tests

Create flow

  1. Open the app and navigate to create a new distance expense
  2. Select the Odometer tab
  3. Enter an extremely large end reading (e.g., start: 0, end: 999999999)
  4. Verify the error message "The total amount is too large. Reduce the distance or lower the rate." appears
  5. Reduce the end reading to a reasonable value and verify you can proceed
  6. Select the Manual distance tab
  7. Enter an extremely large distance value
  8. Verify the same error message appears
  9. Enter a reasonable distance and verify you can proceed
2026-02-19_17-53-02.mp4

Update flow

  1. Create a manual distance expense
  2. Select a large rate ($10)
  3. update the distance
  4. Enter all 9s to the max amount allowed
  5. Verify an error displays instructing to reduce the distance
  6. Change to a rate less than $1
  7. Update the distance to the largest allowed value
  8. Update to the large rate
  9. Verify an error asks you to reduce the rate
  10. Verify the incorrect rate remains selected
  11. Hit the back button
  12. Verify the original rate remains, not the new invalid rate
  13. Update the rate again to the invalid one
  14. Verify the error shows again
  15. Select the original rate
  16. Verify no update is made
2026-02-20_18-16-11.mp4
2026-02-20_18-20-48.mp4

Test with odometer expenses too

  1. Verify the odometer input maxes out at 9,999,999.9
  2. Verify it won't allow adding more numbers
2026-02-22_08-49-44.mp4
  • Verify that no errors appear in the JS console

Offline tests

No offline-specific behavior changes — validation is purely client-side before any API call.

QA Steps

Same as tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

No platform specific changes. See the videos in the tests section.

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

Made with Cursor

@neil-marcellini neil-marcellini requested review from a team as code owners February 22, 2026 22:40
@neil-marcellini neil-marcellini self-assigned this Feb 22, 2026
@melvin-bot melvin-bot bot requested review from mananjadhav and trjExpensify and removed request for a team and trjExpensify February 22, 2026 22:40
@melvin-bot
Copy link

melvin-bot bot commented Feb 22, 2026

@mananjadhav 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]

@melvin-bot melvin-bot bot requested review from a team and removed request for a team February 22, 2026 22:40
@OSBotify
Copy link
Contributor

🦜 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 diff
diff --git a/src/languages/de.ts b/src/languages/de.ts
index b3f46b5f..50c92220 100644
--- a/src/languages/de.ts
+++ b/src/languages/de.ts
@@ -1312,10 +1312,10 @@ const translations: TranslationDeepObject<typeof en> = {
             invalidDistance: 'Bitte gib eine gültige Entfernung ein, bevor du fortfährst',
             invalidReadings: 'Bitte geben Sie sowohl Start- als auch Endstand ein',
             negativeDistanceNotAllowed: 'Endstand muss größer als Anfangsstand sein',
-            distanceAmountTooLarge: 'Der Gesamtbetrag ist zu hoch. Verringere die Entfernung oder reduziere den Satz.',
-            distanceAmountTooLargeReduceDistance: 'Der Gesamtbetrag ist zu hoch. Verringere die Entfernung.',
-            distanceAmountTooLargeReduceRate: 'Der Gesamtbetrag ist zu hoch. Reduziere den Satz.',
-            odometerReadingTooLarge: (formattedMax: string) => `Kilometerstände dürfen ${formattedMax} nicht überschreiten.`,
+            distanceAmountTooLarge: 'Der Gesamtbetrag ist zu hoch. Verringern Sie die Entfernung oder senken Sie den Satz.',
+            distanceAmountTooLargeReduceDistance: 'Der Gesamtbetrag ist zu hoch. Verringern Sie die Entfernung.',
+            distanceAmountTooLargeReduceRate: 'Der Gesamtbetrag ist zu hoch. Senken Sie den Satz.',
+            odometerReadingTooLarge: (formattedMax: string) => `Kilometerzählerstände dürfen ${formattedMax} nicht überschreiten.`,
             invalidIntegerAmount: 'Bitte gib einen vollen Dollarbetrag ein, bevor du fortfährst',
             invalidTaxAmount: (amount: string) => `Der maximale Steuerbetrag ist ${amount}`,
             invalidSplit: 'Die Summe der Aufteilungen muss dem Gesamtbetrag entsprechen',
diff --git a/src/languages/fr.ts b/src/languages/fr.ts
index d63753b4..cd3e4b1f 100644
--- a/src/languages/fr.ts
+++ b/src/languages/fr.ts
@@ -1318,8 +1318,8 @@ const translations: TranslationDeepObject<typeof en> = {
             negativeDistanceNotAllowed: 'Le relevé de fin doit être supérieur au relevé de début',
             distanceAmountTooLarge: 'Le montant total est trop élevé. Réduisez la distance ou diminuez le taux.',
             distanceAmountTooLargeReduceDistance: 'Le montant total est trop élevé. Réduisez la distance.',
-            distanceAmountTooLargeReduceRate: 'Le montant total est trop élevé. Diminuez le taux.',
-            odometerReadingTooLarge: (formattedMax: string) => `Les lectures du compteur kilométrique ne peuvent pas dépasser ${formattedMax}.`,
+            distanceAmountTooLargeReduceRate: 'Le montant total est trop élevé. Réduisez le taux.',
+            odometerReadingTooLarge: (formattedMax: string) => `Les relevés du compteur kilométrique ne peuvent pas dépasser ${formattedMax}.`,
             invalidIntegerAmount: 'Veuillez saisir un montant entier en dollars avant de continuer',
             invalidTaxAmount: (amount: string) => `Le montant maximal de taxe est de ${amount}`,
             invalidSplit: 'La somme des répartitions doit être égale au montant total',
diff --git a/src/languages/it.ts b/src/languages/it.ts
index 714ebdbb..dd397c12 100644
--- a/src/languages/it.ts
+++ b/src/languages/it.ts
@@ -1309,9 +1309,9 @@ const translations: TranslationDeepObject<typeof en> = {
             invalidDistance: 'Inserisci una distanza valida prima di continuare',
             invalidReadings: 'Inserisci sia la lettura iniziale che quella finale',
             negativeDistanceNotAllowed: 'La lettura finale deve essere maggiore della lettura iniziale',
-            distanceAmountTooLarge: "L'importo totale è troppo alto. Riduci la distanza o abbassa la tariffa.",
-            distanceAmountTooLargeReduceDistance: "L'importo totale è troppo alto. Riduci la distanza.",
-            distanceAmountTooLargeReduceRate: "L'importo totale è troppo alto. Abbassa la tariffa.",
+            distanceAmountTooLarge: 'L’importo totale è troppo alto. Riduci la distanza o abbassa la tariffa.',
+            distanceAmountTooLargeReduceDistance: "L'importo totale è troppo elevato. Riduci la distanza.",
+            distanceAmountTooLargeReduceRate: "L'importo totale è troppo alto. Riduci la tariffa.",
             odometerReadingTooLarge: (formattedMax: string) => `Le letture del contachilometri non possono superare ${formattedMax}.`,
             invalidIntegerAmount: 'Inserisci un importo in dollari intero prima di continuare',
             invalidTaxAmount: (amount: string) => `L’importo massimo dell’imposta è ${amount}`,
diff --git a/src/languages/ja.ts b/src/languages/ja.ts
index d675b53e..5b8b2720 100644
--- a/src/languages/ja.ts
+++ b/src/languages/ja.ts
@@ -1303,10 +1303,10 @@ const translations: TranslationDeepObject<typeof en> = {
             invalidDistance: '続行する前に有効な距離を入力してください',
             invalidReadings: '開始値と終了値の両方を入力してください',
             negativeDistanceNotAllowed: '終了値は開始値より大きくなければなりません',
-            distanceAmountTooLarge: '合計金額が大きすぎます。距離を減らすか、レートを下げてください。',
-            distanceAmountTooLargeReduceDistance: '合計金額が大きすぎます。距離を減らしてください。',
+            distanceAmountTooLarge: '合計金額が大きすぎます。距離を短くするか、レートを下げてください。',
+            distanceAmountTooLargeReduceDistance: '合計金額が大きすぎます。距離を短くしてください。',
             distanceAmountTooLargeReduceRate: '合計金額が大きすぎます。レートを下げてください。',
-            odometerReadingTooLarge: (formattedMax: string) => `オドメーターの読み取り値は${formattedMax}を超えることはできません。`,
+            odometerReadingTooLarge: (formattedMax: string) => `オドメーターの数値は ${formattedMax} を超えることはできません。`,
             invalidIntegerAmount: '続行する前にドルの整数金額を入力してください',
             invalidTaxAmount: (amount: string) => `最大税額は${amount}です`,
             invalidSplit: '分割した金額の合計は合計金額と一致している必要があります',
diff --git a/src/languages/nl.ts b/src/languages/nl.ts
index ce230084..017938e4 100644
--- a/src/languages/nl.ts
+++ b/src/languages/nl.ts
@@ -1308,10 +1308,10 @@ const translations: TranslationDeepObject<typeof en> = {
             invalidDistance: 'Voer een geldige afstand in voordat je verdergaat',
             invalidReadings: 'Voer zowel de begin- als eindstanden in',
             negativeDistanceNotAllowed: 'Eindstand moet hoger zijn dan beginstand',
-            distanceAmountTooLarge: 'Het totale bedrag is te hoog. Verlaag de afstand of verlaag het tarief.',
-            distanceAmountTooLargeReduceDistance: 'Het totale bedrag is te hoog. Verlaag de afstand.',
+            distanceAmountTooLarge: 'Het totale bedrag is te hoog. Verkort de afstand of verlaag het tarief.',
+            distanceAmountTooLargeReduceDistance: 'Het totale bedrag is te hoog. Verkort de afstand.',
             distanceAmountTooLargeReduceRate: 'Het totale bedrag is te hoog. Verlaag het tarief.',
-            odometerReadingTooLarge: (formattedMax: string) => `Kilometertellerstanden mogen niet hoger zijn dan ${formattedMax}.`,
+            odometerReadingTooLarge: (formattedMax: string) => `Kilometerstand kan niet hoger zijn dan ${formattedMax}.`,
             invalidIntegerAmount: 'Voer een volledig dollarbedrag in voordat je doorgaat',
             invalidTaxAmount: (amount: string) => `Maximale belastingbedrag is ${amount}`,
             invalidSplit: 'De som van de splitsingen moet gelijk zijn aan het totale bedrag',
diff --git a/src/languages/pl.ts b/src/languages/pl.ts
index 106929ac..b315bbf0 100644
--- a/src/languages/pl.ts
+++ b/src/languages/pl.ts
@@ -1307,10 +1307,10 @@ const translations: TranslationDeepObject<typeof en> = {
             invalidDistance: 'Wprowadź prawidłowy dystans przed kontynuowaniem',
             invalidReadings: 'Wprowadź zarówno odczyt początkowy, jak i końcowy',
             negativeDistanceNotAllowed: 'Końcowy odczyt musi być większy niż początkowy odczyt',
-            distanceAmountTooLarge: 'Łączna kwota jest zbyt wysoka. Zmniejsz dystans lub obniż stawkę.',
-            distanceAmountTooLargeReduceDistance: 'Łączna kwota jest zbyt wysoka. Zmniejsz dystans.',
+            distanceAmountTooLarge: 'Łączna kwota jest zbyt duża. Skróć dystans lub obniż stawkę.',
+            distanceAmountTooLargeReduceDistance: 'Łączna kwota jest zbyt wysoka. Zmniejsz odległość.',
             distanceAmountTooLargeReduceRate: 'Łączna kwota jest zbyt wysoka. Obniż stawkę.',
-            odometerReadingTooLarge: (formattedMax: string) => `Odczyty licznika nie mogą przekraczać ${formattedMax}.`,
+            odometerReadingTooLarge: (formattedMax: string) => `Odczyty z licznika nie mogą przekraczać ${formattedMax}.`,
             invalidIntegerAmount: 'Przed kontynuowaniem wprowadź kwotę w pełnych dolarach',
             invalidTaxAmount: (amount: string) => `Maksymalna kwota podatku to ${amount}`,
             invalidSplit: 'Suma podziałów musi być równa całkowitej kwocie',
diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts
index b55d8a69..d60b2e25 100644
--- a/src/languages/pt-BR.ts
+++ b/src/languages/pt-BR.ts
@@ -1305,10 +1305,10 @@ const translations: TranslationDeepObject<typeof en> = {
             invalidDistance: 'Insira uma distância válida antes de continuar',
             invalidReadings: 'Insira as leituras de início e fim',
             negativeDistanceNotAllowed: 'A leitura final deve ser maior que a leitura inicial',
-            distanceAmountTooLarge: 'O valor total é muito alto. Diminua a distância ou reduza a tarifa.',
-            distanceAmountTooLargeReduceDistance: 'O valor total é muito alto. Diminua a distância.',
-            distanceAmountTooLargeReduceRate: 'O valor total é muito alto. Reduza a tarifa.',
-            odometerReadingTooLarge: (formattedMax: string) => `As leituras do hodômetro não podem exceder ${formattedMax}.`,
+            distanceAmountTooLarge: 'O valor total é muito alto. Reduza a distância ou diminua a tarifa.',
+            distanceAmountTooLargeReduceDistance: 'O valor total é muito alto. Reduza a distância.',
+            distanceAmountTooLargeReduceRate: 'O valor total é muito alto. Reduza a taxa.',
+            odometerReadingTooLarge: (formattedMax: string) => `As leituras do odômetro não podem exceder ${formattedMax}.`,
             invalidIntegerAmount: 'Insira um valor inteiro em dólares antes de continuar',
             invalidTaxAmount: (amount: string) => `O valor máximo de imposto é ${amount}`,
             invalidSplit: 'A soma das divisões deve ser igual ao valor total',
diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts
index 6f216310..9d7c72c4 100644
--- a/src/languages/zh-hans.ts
+++ b/src/languages/zh-hans.ts
@@ -1282,10 +1282,10 @@ const translations: TranslationDeepObject<typeof en> = {
             invalidDistance: '请在继续之前输入有效的距离',
             invalidReadings: '请输入起始读数和结束读数',
             negativeDistanceNotAllowed: '结束读数必须大于开始读数',
-            distanceAmountTooLarge: '总金额过大。请减少距离或降低费率。',
+            distanceAmountTooLarge: '总金额过大。请缩短距离或降低费率。',
             distanceAmountTooLargeReduceDistance: '总金额过大。请减少距离。',
             distanceAmountTooLargeReduceRate: '总金额过大。请降低费率。',
-            odometerReadingTooLarge: (formattedMax: string) => `里程表读数不能超过${formattedMax}。`,
+            odometerReadingTooLarge: (formattedMax: string) => `里程表读数不能超过 ${formattedMax}。`,
             invalidIntegerAmount: '请在继续之前输入一个整数美元金额',
             invalidTaxAmount: (amount: string) => `最高税额为 ${amount}`,
             invalidSplit: '拆分金额之和必须等于总金额',

Note

You can apply these changes to your branch by copying the patch to your clipboard, then running pbpaste | git apply 😉

View workflow run

MelvinBot and others added 15 commits February 22, 2026 14:44
…d limit

Extreme odometer/distance values can produce amounts exceeding the backend
WAF's 12-digit limit (999,999,999,999 cents). When this happens, the WAF
silently strips the amount parameter, causing null amount exceptions during
transaction merge.

This adds client-side validation to all distance expense entry points:
- Odometer page (IOURequestStepDistanceOdometer)
- Manual distance page (IOURequestStepDistanceManual)
- Confirmation list (MoneyRequestConfirmationList) for map/GPS/all types

Also adds a new isDistanceAmountWithinLimit utility in DistanceRequestUtils
and localized error messages in all 10 language files.
Changes single-quoted string with escaped apostrophe to double-quoted
string in the distanceAmountTooLarge translation, matching Prettier's
formatting rules.

Co-authored-by: Neil Marcellini <neil-marcellini@users.noreply.github.com>
When editing the rate on an existing distance expense, validate that
the new rate combined with the existing distance does not exceed the
backend WAF's 12-digit limit (999,999,999,999 cents). Shows the same
distanceAmountTooLarge error message used in the creation flow.

Co-authored-by: Neil Marcellini <neil-marcellini@users.noreply.github.com>
Co-authored-by: Neil Marcellini <neil-marcellini@users.noreply.github.com>
…idation error

When selecting a rate that causes the distance amount to exceed the backend
limit, the page now keeps the problematic rate shown as selected (via local
pendingRateID state) instead of reverting to the previously stored rate. This
makes the error context clear to the user. Selecting a valid rate clears the
error and navigates back normally. Hitting back without fixing leaves the
server-stored rate unchanged.

Also moved the validation check before tax state updates so that an invalid
rate selection does not produce side effects on tax amount/code.

Co-authored-by: Neil Marcellini <neil-marcellini@users.noreply.github.com>
On distance pages (odometer/manual), show "Reduce the distance" only.
On the rate page, show "Lower the rate" only.
The confirmation page keeps the general message mentioning both.

Co-authored-by: Neil Marcellini <neil-marcellini@users.noreply.github.com>
The odometer start/end TextInput fields had no character length
limit, allowing users to enter unreasonably large values. Add
CONST.IOU.ODOMETER_MAX_LENGTH (10 chars, supporting up to
9999999.99) and apply it to both odometer TextInput fields.

Co-authored-by: Neil Marcellini <neil-marcellini@users.noreply.github.com>
maxLength alone is a character count limit, not a numeric limit.
9999999.99 is 10 characters but far exceeds 999,999. Add an explicit
numeric check against ODOMETER_MAX_VALUE (999,999) in handleNext()
and reduce ODOMETER_MAX_LENGTH from 10 to 9 as a UX guardrail.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Commercial vehicles can exceed 1M miles, so raise ODOMETER_MAX_VALUE
to 9,999,999.9 with 1 decimal place. Commas are now stripped as
thousand separators instead of converted to decimal points.
ODOMETER_MAX_LENGTH raised to 11 (7 digits + 2 commas + dot + 1 decimal).

Co-authored-by: Cursor <cursoragent@cursor.com>
Use replaceAllDigits + fromLocaleDigit to convert locale-specific
input to standard format (e.g., European "1.234,5" → "1234.5").
Update error messages to show the actual max of 9,999,999.9 with
locale-appropriate decimal separators in all 10 languages.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Neil Marcellini <neil-marcellini@users.noreply.github.com>
Display values with commas (e.g., 9,999,999.9) as the user types.
Strip commas before all parseFloat calls so numeric operations work
correctly. Fixes amount=0 bug caused by parseFloat stopping at commas.

Co-authored-by: Cursor <cursoragent@cursor.com>
…er-string-replace-all rule

Co-authored-by: Neil Marcellini <neil-marcellini@users.noreply.github.com>
Don't auto-format or restrict what the user types. Accept numbers,
commas, and periods freely. Parse using locale-aware digit conversion
on submit and validate the numeric value against ODOMETER_MAX_VALUE.
Remove maxLength and ODOMETER_MAX_LENGTH since validation is now
purely numeric.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ChavdaSachin
Copy link
Contributor

ChavdaSachin commented Feb 26, 2026

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Screen.Recording.2026-02-27.at.4.24.49.AM.mov
Android: mWeb Chrome
Screen.Recording.2026-02-27.at.4.30.16.AM.mov
iOS: HybridApp
Screen.Recording.2026-02-27.at.4.07.44.AM.mov
iOS: mWeb Safari
Screen.Recording.2026-02-27.at.4.15.21.AM.mov
Screen.Recording.2026-02-27.at.4.19.02.AM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-02-27.at.1.57.25.AM.mov


navigateToNextPage(value);
}, [navigateToNextPage, translate, report, iouType, currentUserAccountIDParam]);
}, [navigateToNextPage, translate, report, iouType, currentUserAccountIDParam, rate]);
Copy link
Contributor

@ChavdaSachin ChavdaSachin Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR refactored the function body but missed to remove the unnecessary dependencies here.
Unused dependencies are safe to remove.

Copy link
Contributor

@ChavdaSachin ChavdaSachin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✅

@melvin-bot melvin-bot bot requested a review from MonilBhavsar February 26, 2026 23:19
@melvin-bot
Copy link

melvin-bot bot commented Feb 26, 2026

@MonilBhavsar 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]

@melvin-bot
Copy link

melvin-bot bot commented Feb 26, 2026

🎯 @ChavdaSachin, thanks for reviewing and testing this PR! 🎉

An E/App issue has been created to issue payment here: #83636.

report, iouType, and currentUserAccountIDParam are not referenced in
the callback body — they were left over from before the refactor moved
logic into navigateToNextPage.

Made-with: Cursor
Copy link
Contributor

@MonilBhavsar MonilBhavsar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Julesssss all yours

@neil-marcellini neil-marcellini merged commit 64974f7 into main Mar 2, 2026
38 checks passed
@neil-marcellini neil-marcellini deleted the neil-distanceAmountValidation-v2 branch March 2, 2026 22:35
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

🚧 @neil-marcellini has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify
Copy link
Contributor

OSBotify commented Mar 2, 2026

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

OSBotify commented Mar 4, 2026

🚀 Deployed to staging by https://github.com/neil-marcellini in version: 9.3.31-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 failure ❌
🍎 iOS 🍎 success ✅

@jponikarchuk
Copy link

Deploy Blocker #84177 was identified to be related to this PR.

@lanitochka17
Copy link

Deploy Blocker ##84220 was identified to be related to this PR.

@jponikarchuk
Copy link

This PR failing because of the issue #84273
This issue is reproducible in: Web, iOS

@Julesssss
Copy link
Contributor

Julesssss commented Mar 5, 2026

@ChavdaSachin could you look into the related issues please (just this one), I have closed two of the others.

@ChavdaSachin
Copy link
Contributor

Yes @Julesssss, this bug was already reported by me - here.
Would raise a PR with help of Melvin.

@OSBotify
Copy link
Contributor

OSBotify commented Mar 6, 2026

🚀 Deployed to production by https://github.com/blimpich in version: 9.3.31-12 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants