Skip to content

Localize Search date range labels - #105878

Merged
roryabraham merged 8 commits into
Expensify:mainfrom
shubham1206agra:localize-dates-search-ranges
Nov 11, 2026
Merged

roryabraham merged 8 commits into
Expensify:mainfrom
shubham1206agra:localize-dates-search-ranges

Conversation

@shubham1206agra

@shubham1206agra shubham1206agra commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

Search date range labels (week groups, quarter groups, the date filter summary and comparison periods) were built by joining two hand-written MMM d dates with -. That keeps the US order and repeats the month, so German showed Sept. 1 - Sept. 7, 2025.

getFormattedDateRangeForSearch and the range inside getFormattedQuarterForSearch now use a cached Intl.DateTimeFormat and its range format, so each language orders and joins the range its own way, and writes a shared month or year once:

Label English (before) English (after) German (after)
Week Sep 1 - Sep 7, 2025 Sep 1 – 7, 2025 1.–7. Sept. 2025
Across years Dec 29, 2025 - Jan 4, 2026 Dec 29, 2025 – Jan 4, 2026 29. Dez. 2025 – 4. Jan. 2026
Quarter Q1 2026 (Jan 1 - Mar 31) Q1 2026 (Jan 1 – Mar 31) Q1 2026 (1. Jan. – 31. März)

The year is shown in exactly the same cases as before. English changes only in punctuation: the range uses an en dash with thin spaces, and a shared month is written once. The compact chart labels (Sep 1 - 7, ’25) keep their styled short year and are not changed here.

Hermes, which runs the app on iOS and Android, has no Intl.DateTimeFormat.prototype.formatRange, and Hermes recommends a polyfill for it. This PR adds formatRange on native from @formatjs/intl-datetimeformat, pinned to 6.12.6:

  • Only one method is added. Hermes's own DateTimeFormat keeps formatting single dates, and formatjs formats the range from the same resolved options. Replacing the whole constructor would also mean shipping time zone data.
  • The data is lazy-loaded. Each language's range data is loaded on demand in IntlStore, like the other formatjs polyfills, and only when the polyfill is installed. The polyfill only installs when formatRange is missing, so it never runs on web and turns itself off once Hermes ships the method.
  • Two cases join two localized dates with an en dash instead. One is a time zone other than UTC, because formatjs would read that zone as UTC without time zone data. The other is the moment before a language's data has loaded, when formatjs would fall back to English. The Search labels format in UTC, so they always get the collapsed range.
  • Why 6.12.6. It shares @formatjs/ecma402-abstract 2.0.0 with the formatjs packages we already use, so nothing is duplicated. formatjs 8 drops the month from Chinese ranges with a year (2026年620日 – 27日), and a unit test guards against upgrading to it.

An unreadable date now gives an empty label instead of throwing.

This is one of a set of small, independent PRs that split up the date-localization work in #105846. They can merge in any order. Each one caches its own Intl.DateTimeFormat next to the function it changes; a follow-up will merge those into one shared helper.

Fixed Issues

$ #98088
PROPOSAL:

Tests

  1. Open Reports > Expenses and group by week.
  2. Verify each week heading reads like Sep 1 – 7, 2025.
  3. Group by quarter and verify headings read like Q1 2026 (Jan 1 – Mar 31).
  4. Open Settings > Preferences > Language and select Deutsch, return to Search, and verify the week headings read like 1.–7. Sept. 2025.
  5. On iOS and Android native builds, repeat steps 1-4 and verify the headings match web.
  • Verify that no errors appear in the JS console

Offline tests

Same as tests.

QA Steps

Same as tests.

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Screenshot 2026-11-11 at 5 14 55 PM Screenshot 2026-11-11 at 5 15 15 PM Screenshot 2026-11-11 at 5 15 58 PM Screenshot 2026-11-11 at 5 16 12 PM

Build getFormattedDateRangeForSearch and the range in
getFormattedQuarterForSearch with a cached Intl.DateTimeFormat range, so each
language orders and joins the range its own way. The year shows in the same
cases as before, engines without formatRange fall back to two joined dates, and
an unreadable date gives an empty label.
A cached Intl.DateTimeFormat keeps the device timezone from when it was
created. Format in UTC and copy the date's current local fields instead.
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR is possibly changing native code and/or updating libraries, it may cause problems with HybridApp. Please check if any patch updates are required in the HybridApp repo and run an AdHoc build to verify that HybridApp will not break. Ask Contributor Plus for help if you are not sure how to handle this. ⚠️

@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/libs/DateUtils.ts 92.33% <100.00%> (+0.04%) ⬆️
src/libs/IntlPolyfill/index.ios.ts 100.00% <100.00%> (ø)
src/libs/IntlPolyfill/index.android.ts 0.00% <0.00%> (ø)
...c/libs/IntlPolyfill/polyfillDateTimeFormatRange.ts 95.83% <95.83%> (ø)
... and 21 files with indirect coverage changes

@shubham1206agra
shubham1206agra marked this pull request as ready for review November 11, 2026 11:48
@shubham1206agra
shubham1206agra requested review from a team as code owners November 11, 2026 11:48
@melvin-bot
melvin-bot Bot requested review from linhvovan29546 and removed request for a team November 11, 2026 11:48
@melvin-bot

melvin-bot Bot commented Nov 11, 2026

Copy link
Copy Markdown

@linhvovan29546 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot
melvin-bot Bot requested review from flaviadefaria and removed request for a team November 11, 2026 11:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T12:05:13.185965Z b4de148 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@shubham1206agra

Copy link
Copy Markdown
Contributor Author

@linhvovan29546 Can you test native devices for this PR?

Comment thread src/libs/DateUtils.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4de148a6b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/libs/DateUtils.ts Resolved
@linhvovan29546

Copy link
Copy Markdown
Contributor

@MelvinBot Review

@MelvinBot

MelvinBot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Web test steps verification results: ⚠️ partial

UI verification remains blocked by expense setup. Static source review separately validates an unguarded reversed-date range reaching Intl.formatRange; this was not browser reproduced.

Location-access modal blocking expense setup

Step Status
1. Open Expenses and group by weekExpenses opened with no existing expenses. Creating an expense encountered a location-access modal whose dismissal button the driver could not click; grouping was not reached.
Location-access modal blocking expense setup
⚠️
2. English collapsed week rangesUnverified: no expense fixtures or week headings available.
⚠️
3. Quarter headingsUnverified: blocked during expense setup.
⚠️
4. German week rangesUnverified: language switching and grouping were not reached.
⚠️
5. Native matching webNot tested in this web-only run.
⚠️
6. No JavaScript console errorsUnverified: console inspection was unavailable through the supported testing commands.
⚠️
7. Offline grouping and language checksUnverified: offline network control was unavailable; expense setup was also blocked.
⚠️
8. Code review: [P2] Handle reversed search dates before formatRangeA query such as date>=2026-09-07 date<=2026-09-01 supplies individually valid dates but reversed bounds. The search-filter formatting path forwards them to DateUtils.ts:1483–1501, which checks validity but not ordering. The new formatRange call throws RangeError instead of rendering the contradictory filter. Guard reversed bounds and add regression coverage through the search-filter display path. Confirmed by static review, not browser reproduction.
❌

view run · no recording available

@linhvovan29546

linhvovan29546 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified any copy / text that was added to the app is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If the PR adds or modifies the UI:
    • I asked an AI agent to review the changes for accessibility issues and addressed its findings.
    • I tested with a screen reader (VoiceOver on macOS) and verified all new/changed elements are reachable with a logical focus order.
    • I verified all new/changed elements have meaningful accessible names and roles.
    • I verified state changes are announced (e.g. checked/unchecked, expanded/collapsed, selected).
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp Screenshot_1794405423 Screenshot_1794405171 Screenshot_1794405088
Android: mWeb Chrome
iOS: HybridApp Simulator Screenshot - iPhone 17 Pro Max - 2026-11-11 at 20 47 31 Simulator Screenshot - iPhone 17 Pro Max - 2026-11-11 at 20 39 19 Simulator Screenshot - iPhone 17 Pro Max - 2026-11-11 at 20 37 06 Simulator Screenshot - iPhone 17 Pro Max - 2026-11-11 at 20 36 30 Simulator Screenshot - iPhone 17 Pro Max - 2026-11-11 at 20 29 28 Simulator Screenshot - iPhone 17 Pro Max - 2026-11-11 at 20 29 04
iOS: mWeb Safari
MacOS: Chrome / Safari

@melvin-bot
melvin-bot Bot requested a review from roryabraham November 11, 2026 14:26

@roryabraham roryabraham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bummer that this one became a lot more complicated because we needed a polyfill for Hermes.

Upstream PRs for that are nearly 3 years old:

@roryabraham
roryabraham merged commit 792ec2c into Expensify:main Nov 11, 2026
46 of 49 checks passed
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/roryabraham in version: 9.5.37-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

No help site update needed — this PR fixes localized date-range formatting without adding a workflow, renaming controls, removing a beta, or making any existing article sentence incorrect.


view run

@shubham1206agra shubham1206agra mentioned this pull request Nov 12, 2026
37 tasks done
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.5.37-1 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 failure ❌
🍎 iOS 🍎 failure ❌

Bundle Size Analysis (Sentry):

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants