Skip to content

[Due for payment 2026-03-30] Odometer - User can input any character in the Odometer input field #84220

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 numbers, commas, full stops

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.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

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

    @melvin-bot

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

  3. melvin-bot commented on Mar 4, 2026

    @melvin-bot

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

  4. melvin-bot commented on Mar 4, 2026

    @melvin-bot

    Triggered auto assignment to @stephanieelliott (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 4, 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 4, 2026

    @OSBotify
    Contributor

    Investigation Summary

    Classification: Frontend bug
    Causing PR: #83170 - "Add frontend validation for distance expense amounts exceeding backend limit (v2)" by @neildotexpensify (High confidence)
    Related Issues: None

    Recommendation: ROLL FORWARD

    The bug is straightforward to fix - the input handlers need to normalize/clean the text before setting it to state. Rolling forward with a fix is simpler than reverting PR #83170, which added important validation logic to prevent backend errors.

    Labels: No label changes needed - this is correctly labeled as DeployBlockerCash (App deploy blocker)

    Detailed Analysis

    Evidence

    PR #83170 refactored the odometer input validation logic, replacing the cleanOdometerReading() function with isOdometerInputValid(). This change introduced a critical bug:

    Before (working):

    const handleStartReadingChange = (text: string) => {
        const cleaned = cleanOdometerReading(text);  // Strips invalid characters
        setStartReading(cleaned);                     // Sets the cleaned value
    }

    After (broken):

    const handleStartReadingChange = (text: string) => {
        if (!isOdometerInputValid(text, startReading)) {
            return;
        }
        setStartReading(text);  // BUG: Sets raw text, not cleaned!
    }

    Verification

    1. The bug is in /home/runner/_work/App/App/src/pages/iou/request/step/IOURequestStepDistanceOdometer.tsx lines 305-323
    2. PR Add frontend validation for distance expense amounts exceeding backend limit (v2) #83170 modified this file on 2026-03-02, changing the input handling logic
    3. The isOdometerInputValid function validates the NORMALIZED text (via DistanceRequestUtils.normalizeOdometerText) but doesn't clean the input before it's set to state
    4. Result: When a user types "abc123", the validation normalizes it to "123" which passes validation, then sets "abc123" to state, displaying the letters in the input field

    Root Cause

    The refactoring separated validation from cleaning. isOdometerInputValid only checks if the normalized text is valid, but handleStartReadingChange and handleEndReadingChange set the raw input text instead of the normalized version.

    Fix Required

    In IOURequestStepDistanceOdometer.tsx, the handlers should normalize the text before setting it:

    const handleStartReadingChange = (text: string) => {
        if (!isOdometerInputValid(text, startReading)) {
            return;
        }
        const normalized = DistanceRequestUtils.normalizeOdometerText(text, fromLocaleDigit);
        setStartReading(normalized);  // Set normalized text
        if (formError) {
            setFormError(''<empty>);
        }
    };

    Same fix needed for handleEndReadingChange.

    Why Not PR #78291?

    Melvin-bot initially assigned this to PR #78291, but that PR only refactored the DiscardChangesConfirmation component and didn't touch the input validation logic. PR #78291 merged after PR #83170 had already introduced the bug.

  7. MelvinBot commented on Mar 4, 2026

    @MelvinBot
    Contributor

    Proposal

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

    The odometer input field (start/end reading) in the "Track Distance > Odometer" flow accepts any character (letters, symbols, etc.) instead of restricting input to numeric values only. Users can type "abc" or any non-numeric string into the odometer fields on web/desktop.

    What is the root cause of that problem?

    The handleStartReadingChange and handleEndReadingChange functions in IOURequestStepDistanceOdometer.tsx call isOdometerInputValid() to validate input, but this function validates the normalized (stripped) text rather than the raw input text.

    The validation flow works like this:

    1. User types a character (e.g., "a") making the input "123a"
    2. isOdometerInputValid("123a", "123") is called
    3. Inside, normalizeOdometerText("123a") strips non-numeric characters via /[^0-9.]/g, producing "123"
    4. Validation checks run against "123" — which passes
    5. setStartReading("123a") stores the raw text (including the "a") in state
    6. The TextInput displays "123a"

    The inputMode={CONST.INPUT_MODE.DECIMAL} and keyboardType={CONST.KEYBOARD_TYPE.DECIMAL_PAD} props on the TextInput only affect the mobile virtual keyboard layout — they do not filter characters on web/desktop where a physical keyboard is used.

    This is in contrast to other numeric inputs in the codebase (e.g., validateAmount in MoneyRequestUtils.ts) which validate the raw text against a strict regex like /^\d{1,N}(\.\d{0,N})?$/ to reject non-numeric keystrokes.

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

    In handleStartReadingChange and handleEndReadingChange in IOURequestStepDistanceOdometer.tsx, add a check that rejects the raw input if it contains non-numeric characters (digits and locale decimal separator only). This should be done before the existing isOdometerInputValid call.

    The simplest approach: normalize the text first and store the normalized result instead of the raw text. Modify both handlers to run the text through normalizeOdometerText (or an equivalent filter) before storing it in state via setStartReading/setEndReading. This way, non-numeric characters are stripped at keystroke time, not just at submit time.

    Alternatively, add a raw-text regex check (similar to validateAmount) that returns early if the raw text contains anything other than digits and the locale decimal separator.

    What alternative solutions did you explore? (Optional)

    An alternative would be using an HTML pattern attribute or type="number" on the underlying <input> element for web. However, this would require platform-specific changes to the TextInput component and is less consistent with the existing codebase pattern where validation is handled in the change handlers.


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

  8. 51 remaining items

  9. ChavdaSachin commented on Mar 23, 2026

    @ChavdaSachin
    Contributor

    I think I am due payment here as well, As I already flagged the bug.
    And I was reviewer for the prior PR while author for the current, It should be considered as a separate issue.

    But since it's a miscellaneous case, I'd happily agree whatever @Julesssss or @neil-marcellini thinks is fair here.

  10. Julesssss commented on Mar 24, 2026

    @Julesssss
    Contributor

    It's semi related and caused a regression from the prior issue. I think it is fair to have no additional payment, as the original issue bonus wasn't halved. Please correct me if I am mistaken though.

  11. melvin-bot commented on Mar 30, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  12. joekaufmanexpensify commented on Mar 30, 2026

    @joekaufmanexpensify
    Contributor

    Sounds good. I am going to pay out @ChavdaSachin's existing contract from #83507 since there is no additional payment to them here 👍 cc @mallenexpensify

  13. melvin-bot commented on Mar 30, 2026

    @melvin-bot

    Payment Summary

    Upwork Job

    BugZero Checklist (@mallenexpensify)

    • (if NewFeature) I have created a PR for any necessary HelpDot updates, or I confirmed no updates are necessary.
    • I have verified the correct assignees and roles are listed above and updated the necessary manual offers
    • I have verified that there are no duplicate or incorrect contracts on Upwork for this job (https://www.upwork.com/ab/applicants//hired)
    • I have verified the PR was not reverted
    • I have applied any discounts due to bugs/regressions introduced by this PR
    • I have paid out the Upwork contracts or cancelled the ones that are incorrect
    • I have verified the payment summary above is correct
  14. mallenexpensify commented on Mar 31, 2026

    @mallenexpensify
    Contributor

    Good to close?

  15. situchan commented on Apr 1, 2026

    @situchan
    Contributor

    Payment is remaining for me

  16. mallenexpensify commented on Apr 1, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @situchan due $250 via NewDot

  17. laurenreidexpensify commented on Apr 16, 2026

    @laurenreidexpensify
    Contributor

    Payment Approved - $250 in New Expensify @situchan

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

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething 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