Skip to content

Migrate YearPickerModal to a @react-navigation modal screen#91106

Open
trasnake87 wants to merge 2 commits into
Expensify:mainfrom
trasnake87:yearpicker-rnav-90469
Open

Migrate YearPickerModal to a @react-navigation modal screen#91106
trasnake87 wants to merge 2 commits into
Expensify:mainfrom
trasnake87:yearpicker-rnav-90469

Conversation

@trasnake87
Copy link
Copy Markdown

@trasnake87 trasnake87 commented May 19, 2026

Explanation of Change

YearPickerModal was a react-native-modal (RIGHT_DOCKED) rendered inside CalendarPicker, driven by local isYearPickerVisible/currentDateView state. Because react-native-modal mounts and animates independently of the native stack, it animated inconsistently with the surrounding @react-navigation screens (the problem described in the parent migration #53493).

This migrates the year picker to a dynamic @react-navigation modal route, following the pattern established by PR #88915 (DynamicExpenseLimitTypeSelectorPage):

  • Adds DYNAMIC_ROUTES.YEAR_SELECTOR and a standalone DynamicYearSelectorPage screen (the year list + search input, built from route query params), wired through ROUTES, SCREENS, ModalStackNavigators, linkingConfig, and navigation types.
  • Lifts the picker result out of CalendarPicker's local state into a transient Onyx key (CALENDAR_PICKER_SELECTED_YEAR), tagged with a per-instance contextID. CalendarPicker is rendered in multiple places, and RangeDatePicker mounts two instances simultaneously, so the result is matched back to the instance that opened the picker via contextID and cleared once consumed.
  • CalendarPicker now navigates to the year route (via createDynamicRoute) and applies the returned year to the displayed date. Hosts that render CalendarPicker inside a popover (DatePickerModal, the Search date dropdown) pass onBeforeOpenYearPicker so the popover is dismissed before the year screen is shown, instead of stacking a screen behind a react-native-modal.
  • Removes YearPickerModal and the now-unused year-list state in CalendarPicker.

Fixed Issues

$ #90469
PROPOSAL: #90469 (comment)

Tests

  1. Open Settings → Profile → Date of birth (or any date field, e.g. an expense's date).
  2. Tap the date field to open the calendar.
  3. Tap the year in the calendar header.
  4. Verify the year selector opens as a screen that slides in like other native screens (not a modal that animates independently), with a working search box.
  5. Select a year and verify you return to the date flow and the calendar is showing the year you picked.
  6. Repeat for a Search date filter (Advanced filters → a date filter → switch to a single date / range) and for Schedule a call, and verify the year selector works in each and updates the correct calendar (for a range, the calendar you opened it from).
  7. Verify the month picker still opens and works as before.
  • Verify that no errors appear in the JS console

Offline tests

The year selector is client-side navigation and writes only to a transient local Onyx value; behavior is identical offline.

  • Verify that no errors appear in the JS console

QA Steps

Same as tests.

  • Verify that no errors appear in the JS console

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 followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • 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 a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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

Android: Native
and_91106_trim.mp4
Android: mWeb Chrome
web_91106_mweb_20260521_040950.mp4
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
web_91106_20260519_202020.mp4

@trasnake87 trasnake87 requested review from a team as code owners May 19, 2026 17:39
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented May 19, 2026

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@melvin-bot melvin-bot Bot requested review from flaviadefaria and parasharrajat and removed request for a team May 19, 2026 17:40
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented May 19, 2026

@parasharrajat 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]

Copy link
Copy Markdown

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

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: 9781e56e2a

ℹ️ 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/ROUTES.ts Outdated
Comment on lines +110 to +122
entryScreens: [
SCREENS.SETTINGS.PROFILE.DATE_OF_BIRTH,
SCREENS.SETTINGS.PROFILE.STATUS_CLEAR_AFTER_DATE,
SCREENS.MONEY_REQUEST.STEP_DATE,
SCREENS.MONEY_REQUEST.STEP_TIME,
SCREENS.MONEY_REQUEST.STEP_TIME_EDIT,
SCREENS.MONEY_REQUEST.SPLIT_EXPENSE_CREATE_DATE_RANGE,
SCREENS.SEARCH.ROOT,
SCREENS.SEARCH.ADVANCED_FILTERS_DATE_RHP,
SCREENS.SEARCH.EDIT_MULTIPLE_DATE_RHP,
SCREENS.CHRONOS_SCHEDULE_OOO_ROOT,
SCREENS.SCHEDULE_CALL,
],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add missing YEAR_SELECTOR entry screens for DatePicker flows

CalendarPicker now always opens the year chooser through a dynamic route, and getStateFromPath() only authorizes that route when the current screen is in DYNAMIC_ROUTES.YEAR_SELECTOR.entryScreens; otherwise it falls back as an unauthorized dynamic route. The new allowlist here omits several screens that still render DatePicker (SCREENS.SETTINGS.WALLET.PERSONAL_CARD_EDIT_TRANSACTION_START_DATE, SCREENS.WORKSPACE.COMPANY_CARDS_ASSIGN_CARD_TRANSACTION_START_DATE, SCREENS.WORKSPACE.COMPANY_CARD_EDIT_TRANSACTION_START_DATE, and SCREENS.DEBUG.DYNAMIC_DETAILS_DATE_TIME_PICKER_PAGE), so tapping the calendar year on those pages will not navigate to the new year selector.

Useful? React with 👍 / 👎.

@trasnake87
Copy link
Copy Markdown
Author

Good catch on the entry screens. Rather than extend the allowlist, I switched YEAR_SELECTOR to entryScreens: ['*'].

Reasoning: CalendarPicker is a generic component reachable from a lot of screens — direct date input fields plus DateSelectPopup, RangeDatePicker, DatePresetFilterBase, ScheduleCallPage, the company/personal card transaction start date pages, the debug datetime picker, and so on. The previous in-place YearPickerModal had no screen restriction, so an explicit allowlist is both a behavior change and inherently fragile — it would silently break the year picker again whenever a new date-input screen is added. The '*' wildcard keeps it reachable from every host and matches the existing generic flows (KEYBOARD_SHORTCUTS, EXIT_SURVEY_*).

Added a regression test in CalendarPickerTest.tsx asserting the route stays unrestricted so this can't quietly regress to a partial allowlist. jest and eslint are green (83b38b6).

@trasnake87 trasnake87 force-pushed the yearpicker-rnav-90469 branch from 83b38b6 to 2a4c5ce Compare May 20, 2026 03:34
Replace the react-native-modal based YearPickerModal, rendered inside
CalendarPicker, with a dynamic @react-navigation route so it animates
consistently with the surrounding native stack.

- Add the DYNAMIC_YEAR_SELECTOR dynamic route and the standalone
  DynamicYearSelectorPage screen (year list + search), built from
  route query params.
- Lift the picker result out of CalendarPicker local state into a
  transient Onyx key, tagged with a per-instance contextID so the
  correct CalendarPicker consumes it (range pickers mount two).
- CalendarPicker navigates to the year route and applies the returned
  year; hosts that render it inside a popover pass onBeforeOpenYearPicker
  to dismiss the popover before the year screen is shown.
- Remove YearPickerModal and the now-unused year list state.
- Update CalendarPicker tests for the navigation flow and add coverage
  for the year selection action.
@trasnake87 trasnake87 force-pushed the yearpicker-rnav-90469 branch from 2a4c5ce to 364652d Compare May 20, 2026 19:11
CalendarPicker is a generic component reached from many screens (date input
fields, DateSelectPopup, RangeDatePicker, DatePresetFilterBase,
ScheduleCallPage, ...). The previous in-place YearPickerModal had no screen
restriction, so a hand-maintained entryScreens allowlist silently broke the
year picker on omitted screens (e.g. company/personal card transaction start
date pages, debug datetime picker). Use the '*' wildcard so the year selector
stays reachable from every CalendarPicker host and does not regress when new
date-input screens are added. Added a regression test asserting the route
remains unrestricted.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/ONYXKEYS.ts 100.00% <ø> (ø)
src/ROUTES.ts 17.62% <ø> (ø)
src/SCREENS.ts 100.00% <ø> (ø)
...s/Search/FilterComponents/DatePresetFilterBase.tsx 60.99% <ø> (ø)
...s/Search/FilterDropdowns/DateSelectPopup/index.tsx 0.00% <ø> (ø)
src/libs/Navigation/linkingConfig/config.ts 76.92% <ø> (ø)
src/libs/actions/CalendarPicker.ts 100.00% <100.00%> (ø)
src/pages/ScheduleCall/ScheduleCallPage.tsx 0.00% <ø> (ø)
src/components/DatePicker/DatePickerModal.tsx 8.33% <0.00%> (-0.37%) ⬇️
...onents/Search/FilterComponents/RangeDatePicker.tsx 0.00% <0.00%> (ø)
... and 3 more
... and 15 files with indirect coverage changes

@trasnake87 trasnake87 force-pushed the yearpicker-rnav-90469 branch from 364652d to 883930e Compare May 20, 2026 19:22
@parasharrajat
Copy link
Copy Markdown
Member

Fix the checklist @trasnake87 and add vids for all platforms.

@trasnake87
Copy link
Copy Markdown
Author

Added the Android: mWeb Chrome video and ticked the offline-steps box (the section was already in the body, just hadn't been checked). iOS to follow.

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.

2 participants