Skip to content

[Due for payment 2026-08-27] Report - Monthly submission date in Next Step differs by one day from date set in Workflows #97875

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: 9.4.50-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/folder/13176703/test-cases/41236816
Email or phone of affected tester (no customers): fischer9966+080426cadm@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: MacOS 26.5.2 / Chrome, Safari. iPhone 17 Pro / 26.5.2. Google Pixel 5 / Android 14
App Component: Workspace Settings

Action Performed:

  1. Go to staging.new.expensify.com or open Expensify App
  2. Login with new gmail account
  3. Create new workspace
  4. Go to Workspace settings > Workflows
  5. Enable Submissions
  6. Set Submission frequency to Monthly
  7. Select any day of the month (1 - 31)
  8. Go to Workspace and create expense (no submit)
  9. Check submission date in Next Step banner

Expected Result:

Monthly submission date in Next Step banner should match the date specified in the workspace settings.

Actual Result:

Monthly submission date in Next Step differs by one day from date set in Workflows

Workaround:

Unknown

Platforms:

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

Screenshots/Videos

Bug7226086_1785892510492.Web-Submission-date-settings-vs-Next-Step.mp4

View all open jobs on GitHub

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

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @mallenexpensify

Activity

  1. added
    Daily
    Bug
    on Aug 5, 2026
  2. applause-bot commented on Aug 5, 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/84e1c32e43f5ef41cef4673df9b9e277da704251bcf227f97c719a117160ddce

  3. MelvinBot commented on Aug 5, 2026

    @MelvinBot
    Contributor

    Proposal

    ⚠️ Automated analysis (high confidence). The Next Step banner is generated client-side in App, so this is fixable here.

    TL;DR: The monthly submit date is built correctly in local time but then re-parsed from a date-only string with new Date(...), which JS interprets as UTC midnight. When formatted back in local time, users in any timezone behind UTC (all of the Americas — the reporter is on Windows Chrome) see the day shifted back by one.

    What is the root cause of that problem?

    In NextStepUtils.ts:196-208, the monthly ETA is built and serialized in local time:

    let etaDateTime = setDate(new Date(), policy?.autoReportingOffset); // e.g. the 15th, local
    ...
    nextStep.eta = {dateTime: format(etaDateTime, 'yyyy-MM-dd')};       // "2026-08-15"

    Then at render time in NextStepUtils.ts:81-84 the date-only string is re-parsed with native new Date(...):

    eta = format(new Date(nextStep.eta.dateTime), formatString); // 'do' → ordinal day

    Per the ECMAScript spec, new Date('2026-08-15') (a date-only ISO string) is parsed as UTC midnight. date-fns format() then renders in the browser's local time. For a negative UTC offset (e.g. America/New_York, UTC-5), UTC midnight of the 15th is 19:00 on the 14th local — so the 'do' ordinal prints "14th" instead of "15th". This matches the reported one-day-earlier symptom exactly, and explains why it only reproduces in UTC-negative timezones.

    The saved setting is not at fault: the day-of-month is stored verbatim (1-based) in policy.autoReportingOffset with no conversion, so this is purely a display bug.

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

    Parse the date-only string as a local date at NextStepUtils.ts:83 instead of letting native new Date() treat it as UTC — e.g. use date-fns parseISO(nextStep.eta.dateTime) (which parses date-only strings as local midnight), or a shared DateUtils local-date parser. Verify no other eta.dateTime producer relies on the current UTC behavior before changing this shared render path.

    Investigation details & alternatives considered
    • Client-side vs backend: The whole Next Step message (including this date) is built optimistically in App via useOptimisticNextStep → getReportNextStep → buildOptimisticNextStep. The backend does not supply this string, so App can fix it.
    • Not a 0-vs-1 index bug: autoReportingOffset is a 1-indexed day-of-month and setDate's dayOfMonth arg is also 1-indexed, so the build step preserves the correct day. The shift is introduced only at the UTC re-parse.
    • Format string: the monthly automatic-submit path uses CONST.DATE.ORDINAL_DAY_OF_MONTH ('do'), so the one-day UTC shift is directly visible as a wrong day number.
    • Alternative considered: serializing/rendering with a full timestamp instead of a date-only string — heavier and unnecessary; parsing as local is the minimal fix.

    Key references:

    • Build (local, correct): NextStepUtils.ts:196-208
    • Render (UTC re-parse — root cause): NextStepUtils.ts:81-84
    • Storage (clean): WorkspaceAutoReportingMonthlyOffsetPage.tsx → setWorkspaceAutoReportingMonthlyOffset in Policy.ts (no date math)

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

  4. added
    External
    on Aug 5, 2026
  5. melvin-bot commented on Aug 5, 2026

    @melvin-bot

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

  6. melvin-bot commented on Aug 5, 2026

    @melvin-bot
  7. ZhenjaHorbach commented on Aug 10, 2026

    @ZhenjaHorbach
    Contributor

    @MelvinBot
    Implement your proposal

  8. MelvinBot commented on Aug 10, 2026

    @MelvinBot
    Contributor

    🤖 Draft PR created: #98132

    Please mark it as "Ready for review" when it is ready for review.

    What it does: Parses the monthly automatic-submit ETA (a date-only yyyy-MM-dd string) with date-fns parseISO in the Next Step render path instead of native new Date(...). Native new Date('2026-08-15') parses as UTC midnight, which shifts the day back by one when formatted in a UTC-negative timezone; parseISO parses it as local midnight so the rendered day matches the day set in Workspace Settings → Workflows.

    Changes:

    • src/libs/NextStepUtils.ts — new Date(nextStep.eta.dateTime) → parseISO(nextStep.eta.dateTime) in buildNextStepMessage.
    • tests/unit/NextStepUtilsTest.ts — added a regression test asserting the monthly automatic-submit ETA renders the day-of-month it encodes.

    Local checks run: NextStepUtilsTest (37 passed), oxfmt, ESLint (0 errors), and typecheck-tsgo — all green. The human co-author still needs to fill in the Tests/QA sections and complete the author checklist before marking the PR ready for review.

  9. melvin-bot commented on Aug 13, 2026

    @melvin-bot

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

  10. ZhenjaHorbach commented on Aug 14, 2026

    @ZhenjaHorbach
    Contributor

    Not overdue
    the PR is being reviewed

  11. 8 remaining items

  12. ZhenjaHorbach commented on Aug 20, 2026

    @ZhenjaHorbach
    Contributor

    Not overdue

  13. melvin-bot commented on Aug 25, 2026

    @melvin-bot

    @ZhenjaHorbach Eep! 4 days overdue now. Issues have feelings too...

  14. added
    Awaiting Payment
    on Aug 25, 2026
  15. melvin-bot commented on Aug 26, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  16. melvin-bot commented on Aug 26, 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
  17. ZhenjaHorbach commented on Aug 27, 2026

    @ZhenjaHorbach
    Contributor

    Contributor+ 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.

    https://github.com/Expensify/App/pull/82549/changes#r3871506841

    • [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: NA

    • [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.

    Regression Test Proposal

    Test:

    1. Open App
    2. Login with new gmail account
    3. Create new workspace
    4. Go to Workspace settings > Workflows
    5. Enable Submissions
    6. Set Submission frequency to Monthly
    7. Select any day of the month (1 - 31)
    8. Go to Workspace and create expense (no submit)
    9. Check submission date in Next Step banner
    10. Verify that monthly submission date in Next Step banner should match the date specified in the workspace settings.

    Do we agree 👍 or 👎

  18. mallenexpensify commented on Aug 27, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @ZhenjaHorbach due $250 via NewDot

  19. garrettmknight commented on Sep 2, 2026

    @garrettmknight
    Contributor

    $250 approved for @ZhenjaHorbach

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

Metadata

Metadata

Labels

Awaiting PaymentBugDailyExternal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions