Skip to content

[Due for payment 2026-09-04] Expensify card-Validity dates briefly change to incorrect dates after changing the Limit type #99336

Closed

Description

@applause-bot

If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.


Version Number: v9.4.59-0
Reproducible in staging?: Yes
Reproducible in production?: Yes
If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://test-management.browserstack.com/projects/2219752/test-runs/70387627/folder/13176890/92190317/1686039163?sort=%2Bidentifier
Email or phone of affected tester (no customers): n/a
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Mav 26.5.1 Safari/Chrome, iPhone 13 iOS 26.6
App Component: Workspace Settings

Action Performed:

Precondition: Admin assigned a single-use card with the validity dates

  1. Go to https://staging.new.expensify.com
  2. Navigate to Workspace > Expensify Card
  3. Click on the card from the precondition
  4. Click on "Limit type" in the RHP
  5. Change the selection
  6. Click Save

Expected Result:

The validity dates should remain unchanged when changing the Limit type.

Actual Result:

Validity dates briefly change to incorrect dates after changing the Limit type

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7239893_1787384930844.Recording__2833.mp4

View all open jobs on GitHub

Applause Internal Information
Exported by: Svetlana Lazutkina
Bug ID: 7239893

Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Aug 24, 2026
  2. applause-bot commented on Aug 24, 2026

    @applause-bot
    Author

    While Applause doesn't embed attachments for this bug, here are the links for quick view:
    https://platform.applause.com/services/links/v1/external/2f91f3b8844c0caebce5f997a38760b2053e5be36ac3cb30f2c8551b089a848b

  3. MelvinBot commented on Aug 24, 2026

    @MelvinBot
    Contributor

    Proposal

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

    Changing an Expensify Card's Limit type makes the validity dates of a single-use card briefly flicker to the wrong dates (typically off by one day) before snapping back to the correct values once the server responds.

    What is the root cause of that problem?

    The optimistic update writes the raw date-picker strings (yyyy-MM-dd) into the card's nameValuePairs.validFrom / validThru, but the RHP reads those fields as UTC datetimes. Reinterpreting a bare yyyy-MM-dd as UTC-midnight and projecting it into an assignee timezone behind UTC shifts the date back a day.

    Inside updateExpensifyCardLimitType, the optimisticData and the API parameters are inconsistent:

    The RHP renders the range via getCardHintText, which assumes a UTC datetime, so the optimistic (plain-date) value renders as the previous calendar day for assignees behind UTC until the backend response replaces it.

    Evidence chain

    Because the optimistic merge lands in the same WORKSPACE_CARDS_LIST collection the RHP reads, the wrong-format value is displayed until successData / the backend refresh replaces it with the properly normalized UTC datetime — producing the flicker. The shift only appears for assignees in timezones behind UTC, which is why it reads as a brief off-by-one.

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

    Make the optimistic data use the same normalized values already sent to the API, so the field format is consistent with what the display expects. In updateExpensifyCardLimitType, compute the normalized dates once and reuse them in both optimisticData and parameters:

    const normalizedValidFrom = validFrom ? DateUtils.normalizeDateToStartOfDay(validFrom, timeZone) : undefined;
    const normalizedValidThru = validThru ? DateUtils.normalizeDateToEndOfDay(validThru, timeZone) : undefined;

    Then in optimisticData:

    validFrom: shouldClearValidityDates ? null : normalizedValidFrom,
    validThru: shouldClearValidityDates ? null : normalizedValidThru,

    and pass the same variables into parameters. This eliminates the format mismatch and the transient one-day shift.

    What alternative solutions did you explore?

    Alternatively, keep the optimistic value raw but make getCardHintText tolerate a bare yyyy-MM-dd (skip the UTC re-projection when there's no time component). This is riskier because the display helper is shared with the server-normalized values; unifying the optimistic write to the normalized format is the smaller, safer change.

    Confidence: High — the code path is traced end-to-end and the format inconsistency is explicit in the same function.


    Next Steps for Contributor+ team:
    To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/99336) to create a draft PR.
    To refine: @MelvinBot <your feedback>
    To reject: Explain why you are rejecting Melvin's proposal.


    view run

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Aug 24, 2026
  5. melvin-bot commented on Aug 24, 2026

    @melvin-bot

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

  6. melvin-bot commented on Aug 24, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  7. cretadn22 commented on Aug 27, 2026

    @cretadn22
    Contributor

    @MelvinBot implement this

  8. MelvinBot commented on Aug 27, 2026

    @MelvinBot
    Contributor

    🤖 Draft PR created: #99647
    Please mark it as "Ready for review" when it is ready for review.

    What changed: Implemented the approved proposal. updateExpensifyCardLimitType in src/libs/actions/Card.ts now computes the normalized validity dates once and reuses them in both the optimistic Onyx update and the API parameters. Previously the optimistic write stored raw yyyy-MM-dd picker strings while the params sent UTC datetimes — the RHP renders that field as a UTC datetime, so the un-normalized optimistic value showed the previous calendar day for assignees behind UTC until the backend response replaced it (the flicker). Aligning the formats removes the transient off-by-one shift. The failure path is unaffected (it restores the previously stored, already-normalized values).

    Diff
    +    const normalizedValidFrom = validFrom ? DateUtils.normalizeDateToStartOfDay(validFrom, timeZone) : undefined;
    +    const normalizedValidThru = validThru ? DateUtils.normalizeDateToEndOfDay(validThru, timeZone) : undefined;
    ...
    -                        validFrom: shouldClearValidityDates ? null : validFrom,
    -                        validThru: shouldClearValidityDates ? null : validThru,
    +                        validFrom: shouldClearValidityDates ? null : normalizedValidFrom,
    +                        validThru: shouldClearValidityDates ? null : normalizedValidThru,
    ...
    -        validFrom: validFrom ? DateUtils.normalizeDateToStartOfDay(validFrom, timeZone) : undefined,
    -        validThru: validThru ? DateUtils.normalizeDateToEndOfDay(validThru, timeZone) : undefined,
    +        validFrom: normalizedValidFrom,
    +        validThru: normalizedValidThru,

    Checks: lint-changed ✅ and typecheck ✅ both pass. No existing unit test covers updateExpensifyCardLimitType.

    App smoke test (web): pass — the app builds and the workspace/navigation area around the change renders cleanly. Note: the exact repro requires a precondition (admin-assigned single-use card with validity dates on an assignee behind UTC) that the test account doesn't have, so the limit-type flow itself couldn't be exercised end-to-end — that's left for QA/human testing per the PR's Tests/QA steps.

    Step Status Observation
    App loads to Home after sign-in ✅ pass Home rendered with tabs and dashboard content
    Settings > Workspaces renders without crash ✅ pass Account has no workspaces; standard "No workspaces yet" empty state rendered, no error boundary
    Evidence (2)

    Home screen after sign-in

    Home screen after sign-in

    Workspaces list empty state

    Workspaces list empty state

    view run

  9. melvin-bot commented on Aug 27, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  10. 9 remaining items

  11. melvin-bot commented on Aug 31, 2026

    @melvin-bot

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

  12. cretadn22 commented on Sep 2, 2026

    @cretadn22
    Contributor

    BugZero Checklist:

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

      Link to the comment on the PR: [Single-use and Expire-by virtual cards]: update edit card flow #81783 (comment)
      Link to the comment on the Issue: N/A

    • [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/679851

    Regression Test Proposal

    Test:

    1. Precondition: an admin has assigned a single-use Expensify Card with validity dates (validFrom / validThru) set, using an assignee account in a timezone behind UTC.
    2. Go to Workspace > Expensify Card and open that card.
    3. Click "Limit type" in the RHP, change the selection, and click Save.
    4. Verify the validity dates shown on the card do not flicker/change to an incorrect (off-by-one) date at any point — they should stay stable through the optimistic update and the server response.

    Do we agree 👍 or 👎

    Zapier Logs Run ID: 00040eee-5d70-aa97-6143-240dd9555a84
  13. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    on Sep 3, 2026
  14. melvin-bot commented on Sep 3, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  15. melvin-bot commented on Sep 3, 2026

    @melvin-bot

    Payment Summary

    Resolving PRs:

    BugZero Checklist (@mallenexpensify)

    • I have confirmed assignees, roles, and Upwork contracts look correct
    • I have paid out Upwork contracts / manual NewDot requests
    • [BugZero Assignee] I have created a GH issue for creating/updating the regression test once above steps have been agreed upon
  16. cretadn22 commented on Sep 8, 2026

    @cretadn22
    Contributor

    @mallenexpensify friendly ping that this is due for payment. Thanks!

  17. mallenexpensify commented on Sep 8, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @cretadn22 due $250 via NewDot

  18. JmillsExpensify commented on Sep 9, 2026

    @JmillsExpensify
    Contributor

    $250 approved for @cretadn22

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

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions