Skip to content

Odometer - User can input any character in the Odometer input field #84222

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: v9.3.31-1
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #78291
Email or phone of affected tester (no customers): applausetester+ds@applause.expensifail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mac 14.5/ Chrome
App Component: Other

Action Performed:

  1. Navigate to https://staging.new.expensify.com/
  2. Click on the + button > Track Distance
  3. Switch to Odometer
  4. Write any character on the field

Expected Result:

User is only able to input number

Actual Result:

User can input any character

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7094089_1772660113080.Screen_Recording_2026-03-05_at_12.28.22_at_night.1.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @DylanDylann

Activity

  1. added
    DeployBlockerCashThis issue or pull request should block deployment
    BugSomething is broken. Auto assigns a BugZero manager.
    on Mar 5, 2026
  2. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #78291

  3. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. melvin-bot commented on Mar 5, 2026

    @melvin-bot

    Triggered auto assignment to @garrettmknight (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  5. github-actions commented on Mar 5, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  6. OSBotify commented on Mar 5, 2026

    @OSBotify
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #78291 - "Migrate useBeforeRemove to usePreventRemove in DiscardChangesConfirmation" by @mkzie2 (High confidence)
    Related Issues: #76326

    Recommendation: REVERT

    PR #78291 modified IOURequestStepDistanceOdometer.tsx as part of migrating to usePreventRemove. The changes introduced a regression in input validation that allows users to type any character (including letters) in the odometer input fields on web/Chrome.

    Labels: This is a frontend bug. Keeping DeployBlockerCash label as appropriate for App deploy blocker.

    📋 Detailed Analysis

    Evidence

    Verification

    Files affected by the bug:

    • /home/runner/_work/App/App/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx (lines 280-323, 520-578)
    • /home/runner/_work/App/App/src/libs/DistanceRequestUtils.ts (lines 487-490)

    Confirmed that PR #78291 modified IOURequestStepDistanceOdometer.tsx.

    Root Cause

    The validation logic in isOdometerInputValid() has a flaw where it accepts any input that normalizes to an empty string or NaN:

    1. User types a non-numeric character like "a"
    2. normalizeOdometerText("a", fromLocaleDigit) strips it to an empty string ""
    3. parseFloat("") returns NaN
    4. The validation checks !Number.isNaN(value) && value > MAX which is false for NaN
    5. The function returns true, allowing the invalid input

    The validation should explicitly reject input where:

    • The normalized text differs from the original input (indicating non-numeric chars were present)
    • The normalized text is empty but the original input was not
    • The parsed value is NaN (except for empty string)

    On web/Chrome, keyboardType and inputMode only provide UI hints and do not enforce validation, so the isOdometerInputValid function is critical for preventing invalid input.

  7. MelvinBot commented on Mar 5, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    The odometer input field in Track Distance accepts any character (letters, symbols), not just numeric input. This happens on desktop web where keyboardType/inputMode props are only hints and don't restrict physical keyboard input.

    What is the root cause of that problem?

    The root cause is in PR #83170 (not #78291 as initially attributed). PR #83170 refactored the per-keystroke validation from a "clean-then-store" pattern to a "validate-stripped-but-store-raw" pattern.

    Production (v9.3.30-3) uses cleanOdometerReading which strips non-numeric characters and stores the cleaned result — letters never appear.

    Staging (v9.3.31-1) uses isOdometerInputValid (IOURequestStepDistanceOdometer.tsx:280-303) which calls normalizeOdometerText (DistanceRequestUtils.ts:487-490) to strip non-numeric characters, then validates the stripped result — but the handler stores the raw unstripped text in state.

    The flow: user types "abc" → normalizeOdometerText("abc") strips to "" → parseFloat("") is NaN → max-value check is skipped → validation returns true → setStartReading("abc") stores the raw text with letters.

    PR #78291 only changed DiscardChangesConfirmation from useBeforeRemove to usePreventRemove and migrated refs to state. It did not modify the input validation logic.

    What changes do you think we should make in order to solve the problem?

    In isOdometerInputValid in IOURequestStepDistanceOdometer.tsx, add a check that rejects input containing characters other than digits, locale decimal separators, and locale group separators. This should happen before the normalization step:

    // Early in isOdometerInputValid, after the !text check:
    // Reject input containing non-numeric characters (digits + locale decimal/group separators only)
    

    This ensures the validation guards against raw text on web where inputMode='decimal' doesn't prevent character entry.

    What alternative solutions did you explore? (Optional)

    An alternative would be to revert to the production pattern of cleaning/stripping the text before storing it (i.e., setStartReading(normalizedText) instead of setStartReading(text)). This would also work but would silently strip characters rather than rejecting them, which is a different UX choice. The regex validation approach is preferable because it rejects invalid input outright while preserving the validate-on-input architecture from PR #83170.


    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, or @MelvinBot <your feedback> to refine this analysis.

  8. added and removed
    DeployBlockerCashThis issue or pull request should block deployment
    on Mar 5, 2026
  9. Julesssss commented on Mar 5, 2026

    @Julesssss
    Contributor

    Not a blocker, Odometer feature behind beta.

  10. Julesssss commented on Mar 5, 2026

    @Julesssss
    Contributor

    dupe of #84220

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

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2Engineering

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions