Skip to content

[Due for payment 2025-10-13] [$250] App crashes when trying remove data in the DateTime fields #71345

Closed

Description

@nlemma

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: 9.2.18-5
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from TestRail: #70629
Email or phone of affected tester (no customers): N/A
Issue reported by: Applause Internal Team
Device used: iPhone 15 iOS 18.5
App Component: Other

Action Performed:

  1. Sign on to ND
  2. Go to account > troubleshoot and turn on debug mode
  3. Create new, empty workspace
  4. Add a new report with one expense
  5. Add a second report with one expense - it has to have same amount, merchant and category in order to become a potential duplicate with the previous one
  6. Navigate to the Inbox and press View button to open DebugReportPage
  7. Scroll down to the DateTime fields
  8. Open one of the Daytime field, verify the cursor is at the end of the Time
  9. Try to change the data by tapping "<" button on the opened keyboard

Expected Result:

When tapping "<" button, the last number changes to 0

Actual Result:

When tapping "<" button, the app crashes

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug6955797_1758828768826.Crash.mp4

Bug6955797_1758828768828!Crash_1.txt

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021971607717983899704
  • Upwork Job ID: 1971607717983899704
  • Last Price Increase: 2025-09-26
  • Automatic offers:
    • andriivitiv | Contributor | 108957694
Issue OwnerCurrent Issue Owner: @
Issue OwnerCurrent Issue Owner: @RachCHopkins

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Sep 25, 2025
  2. melvin-bot commented on Sep 25, 2025

    @melvin-bot

    Triggered auto assignment to @RachCHopkins (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.

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Sep 26, 2025
  4. changed the title [-]App crashes when trying remove data in the DateTime fields[/-] [+][$250] App crashes when trying remove data in the DateTime fields[/+] on Sep 26, 2025
  5. melvin-bot commented on Sep 26, 2025

    @melvin-bot
  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Sep 26, 2025
  7. melvin-bot commented on Sep 26, 2025

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee (External)

  8. andriivitiv commented on Sep 26, 2025

    @andriivitiv
    Contributor

    🚨 Edited by proposal-police: This proposal was edited at 2025-09-26 18:18:41 UTC.

    Proposal

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

    App crashes when trying remove data in the DateTime fields

    What is the root cause of that problem?

    We subtract normalizedFrom from normalizedTo, which results in a negative value:

    function replaceRangeWithZeros(originalString: string, from: number, to: number, numOfDigits = 2): string {
    const normalizedFrom = Math.max(from, 0);
    const normalizedTo = Math.min(to, numOfDigits);
    const replacement = '0'.repeat(normalizedTo - normalizedFrom);

    This causes the .repeat(...) function throws an error because it only accepts positive numbers

    The error

    Image

    The values of normalizedFrom and normalizedTo are determined by the selectionMillisecond state variable, which is first passed to clearSelectedValue(...)

    clearSelectedValue(milliseconds, selectionMillisecond, setMilliseconds, setSelectionMillisecond, 3);

    and then to replaceRangeWithZeros(...)

    const positionBeforeSelection = Math.max(selection.start - 1, 0);
    newValue = replaceRangeWithZeros(value, positionBeforeSelection, selection.start, numOfDigits);

    The root cause appears to be that selectionMillisecond is initialized with an incorrect range. Specifically, when showFullFormat is true, it incorrectly sets both start and end to 6, which results in an invalid range and ultimately causes the negative value used in .repeat(...).

    Unfortunately, I can't confirm that this is the exact cause of the crash in the Hybrid app, as I don't have access to its repo. In the Standalone ND app, the error is simply logged to the console. While that button doesn't work, the app itself remains functional and continues to work.

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

    We need to update this line to set the correct number of digits the milliseconds input has:

    -const [selectionMillisecond, setSelectionMillisecond] = useState(showFullFormat ? {start: 6, end: 6} : {start: 0, end: 0});
    +const [selectionMillisecond, setSelectionMillisecond] = useState(showFullFormat ? {start: 3, end: 3} : {start: 0, end: 0});
    // or better
    +const [selectionMillisecond, setSelectionMillisecond] = useState(showFullFormat ? {start: milliseconds.length, end: milliseconds.length} : {start: 0, end: 0});

    What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

    Add a test for the TimePicker component that simulates pressing the < button and verifies that no uncaught error is thrown, and confirms that the value is correctly removed.

  9. self-assigned this
    on Sep 26, 2025
  10. dangrous commented on Sep 26, 2025

    @dangrous
    Contributor

    Happy to shepherd this internally when ready!

  11. melvin-bot commented on Sep 29, 2025

    @melvin-bot

    @jjcoffee Whoops! This issue is 2 days overdue. Let's get this updated quick!

  12. 10 remaining items

  13. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed on Oct 6, 2025
  14. changed the title [-][$250] App crashes when trying remove data in the DateTime fields[/-] [+][Due for payment 2025-10-13] [$250] App crashes when trying remove data in the DateTime fields[/+] on Oct 6, 2025
  15. melvin-bot commented on Oct 6, 2025

    @melvin-bot

    Reviewing label has been removed, please complete the "BugZero Checklist".

  16. melvin-bot commented on Oct 6, 2025

    @melvin-bot

    The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.23-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

    If no regressions arise, payment will be issued on 2025-10-13. 🎊

    For reference, here are some details about the assignees on this issue:

  17. melvin-bot commented on Oct 6, 2025

    @melvin-bot

    @jjcoffee @RachCHopkins The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]

  18. jjcoffee commented on Oct 10, 2025

    @jjcoffee
    Contributor

    BugZero Checklist:

    • [Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.

      Link to comment: https://github.com/Expensify/App/pull/45481/files#r2420679708

    • [Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.

      Link to discussion: N/A

    • [Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.

    • [BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.

      Link to issue: https://github.com/Expensify/Expensify/issues/556949

    Regression Test Proposal

    Test:

    1. Go to Account > Troubleshoot and turn on Debug mode
    2. Create a new workspace if not already
    3. Navigate to the Inbox and press the View button to open DebugReportPage
    4. Scroll down and open one of the DateTime fields
    5. Try to change the time by tapping the "<" button on the opened keyboard
    6. Verify that the last digit is being replaced with 0

    Do we agree 👍 or 👎

  19. RachCHopkins commented on Oct 14, 2025

    @RachCHopkins
    Contributor

    Payment Summary:

    • Contributor: @andriivitiv to be paid $250 via Upwork
    • Contributor+: @jjcoffee paid $250 via NewDot Manual Request

    Upwork job here

  20. RachCHopkins commented on Oct 14, 2025

    @RachCHopkins
    Contributor

    Contributor has been paid, the contract has been completed, and the Upwork post has been closed.

    🟢 to @jjcoffee to request payment in NewDot.

  21. JmillsExpensify commented on Oct 14, 2025

    @JmillsExpensify
    Contributor

    $250 approved for @jjcoffee

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.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions