Skip to content

Recreate: Migrate InitialListValueSelectorModal to dynamic @react-navigation route (with regression fixes)#94014

Open
MelvinBot wants to merge 3 commits into
mainfrom
claude-recreateMigrateInitialListValueSelector
Open

Recreate: Migrate InitialListValueSelectorModal to dynamic @react-navigation route (with regression fixes)#94014
MelvinBot wants to merge 3 commits into
mainfrom
claude-recreateMigrateInitialListValueSelector

Conversation

@MelvinBot

@MelvinBot MelvinBot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

This recreates PR #91627 (which was merged and then reverted) and additionally fixes the three regressions it introduced.

Original migration (recreated):
Migrates InitialListValueSelectorModal from a react-native-modal-backed <Modal> to a @react-navigation dynamic route screen, as part of the parent migration effort (#53493).

  • Added a new dynamic route WORKSPACE_REPORT_FIELDS_INITIAL_LIST_VALUE with path suffix initial-list-value and REPORT_FIELDS_CREATE as its entry screen
  • Created DynamicReportFieldsInitialListValuePage that reads from / writes to the WORKSPACE_REPORT_FIELDS_FORM draft via Onyx, preserving the existing toggle behavior (re-selecting clears the value)
  • Uses useDynamicBackPath for correct back navigation including deeplink scenarios
  • Simplified InitialListValueSelector/index.tsx to a stateless menu item that navigates to the dynamic route via createDynamicRoute
  • Deleted InitialListValueSelectorModal.tsx

Regression fixes added on top:

  • Initial value page opens with no list value after refreshing the page — As a standalone route, the page could be refreshed/deeplinked without the transient form draft being populated, rendering an empty picker. The page now redirects back to the Add field page when there are no available (non-disabled) list values, mirroring the guard used on the create page. A loading indicator is shown while the draft is loading / the redirect is in flight.
  • Initial value content overlaps with device status bar (Android & iOS) — The page carried includePaddingTop={false} from the old modal. That was only safe inside the previous RIGHT_DOCKED <Modal>; on a standalone native screen it removes the top safe-area padding and overlaps the status bar. Removed the prop so the default top padding applies.
  • Initial value error persists after selecting an initial value — The value is selected on the separate dynamic route, which writes directly to the form draft and bypasses the form's onInputChange, so the FormProvider validation error was never cleared. The menu item now syncs the draft initial value back into the form, which updates the form value and clears the existing error.

Fixed Issues

$ #90472
$ #93138
$ #93141
$ #93186
PROPOSAL:

Tests

  1. Go to a workspace: Settings > Workspaces > [any workspace] > Reports (enable Report fields / upgrade if needed)
  2. Tap Add field → enter a name → select type List → add a few list values (e.g. "Alpha", "Beta", "Gamma")
  3. Tap Initial value, verify the value picker opens showing your list values, select one (e.g. "Beta"), verify you return and the field shows "Beta"
  4. Re-open Initial value, tap "Beta" again to deselect — verify the field clears
  5. [Due for payment 2026-06-18] [Due for payment 2026-06-17] [$250] Report fields - Initial value page opens with no list value after refreshing the page #93138: With list values added, open Initial value, then refresh the page — verify the app returns to the Add field page (no empty Initial value page)
  6. [Due for payment 2026-06-18] [Due for payment 2026-06-17] [$250] Android & iOS - Report fields - Initial value content overlaps with device status bar #93141 (Android/iOS native): Open Initial value — verify the content does not overlap the device status bar
  7. [Due for payment 2026-06-18] [Due for payment 2026-06-17] Report fields - Initial value error persists after selecting an initial value #93186: Enter a name and save, select type List, add a list value, go back, tap Save to trigger the Initial value required error, then open Initial value and select a value — verify the error is dismissed after selecting
  8. Save the report field and verify it is created with the correct initial value
  • Verify that no errors appear in the JS console

Offline tests

  1. On the Create Report Field page with type List and some list values added, go offline
  2. Tap Initial value, verify the picker opens and you can select/deselect values (all local form state)
  3. Go back online — no errors should appear

QA Steps

  1. Go to a workspace: Settings > Workspaces > [any workspace] > Reports
  2. Tap Add field, enter a name, select type List, add at least two list values
  3. Tap Initial value, select a value, verify it persists on the form; re-open and toggle it off, verify it clears
  4. Refresh while on the Initial value page and verify you return to the Add field page
  5. On Android/iOS native, verify the Initial value page content does not overlap the status bar
  6. Trigger the Initial value required error (Save with no initial value), then select a value and verify the error dismisses
  7. Save the report field and verify the initial value is correct
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • I followed proper code patterns (see Reviewing the code)
  • I followed the guidelines as stated in the Review Guidelines
  • I verified that this PR follows the proper file naming conventions
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.

Screenshots/Videos

Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
- [ ] I verified that similar component doesn't exist in the codebase - [ ] I verified that all props are defined accurately and each prop has a `/** comment above it */` - [ ] I verified that each file is named correctly - [ ] I verified that each component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone - [ ] I verified that the only data being stored in component state is data necessary for rendering and nothing else - [ ] In component if we are not using the full Onyx data that we loaded, I've added the proper selector in order to ensure the component only re-renders when the data it is using changes - [ ] For Class Components, any internal methods passed to components event handlers are bound to `this` properly so there are no scoping issues (i.e. for `onClick={this.submit}` the method `this.submit` should be bound to `this` in the constructor) - [ ] I verified that component internal methods bound to `this` are necessary to be bound (i.e. avoid `this.submit = this.submit.bind(this);` if `this.submit` is never passed to a component event handler like `onClick`) - [ ] I verified that all JSX used for rendering exists in the render method - [ ] I verified that each 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

Screenshots/Videosundefined

…egression fixes

Re-applies the migration of InitialListValueSelectorModal to a @react-navigation
dynamic route (originally #91627) and adds fixes for the regressions
it introduced:

- Issue 93138: redirect back to the Add field page when the dynamic Initial value
  page is opened via refresh/deeplink without available list values, instead of
  rendering an empty picker.
- Issue 93141: drop includePaddingTop={false} so the page no longer overlaps the
  device status bar on native (the prop was only safe inside the old RIGHT_DOCKED modal).
- Issue 93186: sync the draft initial value back into the form so the validation
  error clears after a value is selected on the dynamic route.

Co-authored-by: Shridhar Goel <ShridharGoel@users.noreply.github.com>
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

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/ROUTES.ts 21.11% <ø> (+0.25%) ⬆️
src/SCREENS.ts 100.00% <ø> (ø)
...gation/linkingConfig/RELATIONS/WORKSPACE_TO_RHP.ts 100.00% <ø> (ø)
src/libs/Navigation/linkingConfig/config.ts 76.92% <ø> (ø)
...pages/workspace/reports/CreateReportFieldsPage.tsx 0.00% <ø> (ø)
...lueSelector/ReportFieldsInitialListValuePicker.tsx 0.00% <ø> (ø)
...gation/AppNavigator/ModalStackNavigators/index.tsx 6.50% <0.00%> (-0.02%) ⬇️
...rkspace/reports/InitialListValueSelector/index.tsx 0.00% <0.00%> (ø)
...lector/DynamicReportFieldsInitialListValuePage.tsx 0.00% <0.00%> (ø)
... and 133 files with indirect coverage changes

…icator

Co-authored-by: Shridhar Goel <ShridharGoel@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Fixed the failing typecheck check.

Root cause: main added a required reasonAttributes prop to FullScreenLoadingIndicator, but this PR rendered it without one:

src/pages/workspace/reports/InitialListValueSelector/DynamicReportFieldsInitialListValuePage.tsx(79,22): error TS2741: Property 'reasonAttributes' is missing in type '{}' but required in type 'FullScreenLoadingIndicatorProps'.

Fix: Passed reasonAttributes to the indicator, matching the established pattern used by other migrated pages (e.g. DynamicNewReportWorkspaceSelectionPage):

<FullScreenLoadingIndicator
  reasonAttributes={{
    context: "DynamicReportFieldsInitialListValuePage",
    isLoadingFormDraft: !!isLoadingFormDraft,
  }}
/>

Verified locally with typecheck-tsgo (passes), prettier, and lint-changed.

The other failing check, PR Author Checklist / checklist, is the human author checklist and is out of scope for me to fill out.

@ShridharGoel

ShridharGoel commented Jun 20, 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 proper code patterns were followed (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 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)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • 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 and each prop has a /** comment above it */
    • The file is named correctly
    • 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
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • 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 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 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.
  • 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
Android: mWeb Chrome
iOS: HybridApp
Screen.Recording.2026-06-21.at.12.03.39.AM.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-06-20.at.11.47.44.PM.mov

@ShridharGoel

Copy link
Copy Markdown
Contributor

@MelvinBot #93186 is still not fixed.

…ute (issue 93186)

Co-authored-by: Shridhar Goel <ShridharGoel@users.noreply.github.com>
@MelvinBot

Copy link
Copy Markdown
Contributor Author

Good catch — the previous attempt at the \#93186 fix didn't actually work. Fixed and pushed in 8ac54ef.

Why it was still broken: the menu item only synced the draft value into the form when draftInitialValue !== value. But FormProvider.tsx:154-156 already merges any draft write into inputValues (the value prop) before this effect runs, so draftInitialValue === value was always true by then. The effect returned early, onInputChange was never called, onValidate never ran, and the required error lingered.

Fix: detect the draft change via a ref instead of comparing against the (already-synced) value, so onInputChange fires whenever the selected value changes — which triggers onValidate and clears the stale error. See InitialListValueSelector/index.tsx.

Local checks passed: prettier, lint (clean on the changed file), and typecheck-tsgo. Please re-test the error-dismissal flow (steps 7 in the PR description) and re-run the full check suite.

@ShridharGoel

Copy link
Copy Markdown
Contributor

@MelvinBot Mark it as ready for review

@MelvinBot MelvinBot marked this pull request as ready for review June 20, 2026 18:46
@MelvinBot MelvinBot requested a review from a team as a code owner June 20, 2026 18:46
@melvin-bot melvin-bot Bot requested review from joekaufmanexpensify and thelullabyy and removed request for a team June 20, 2026 18:46
@melvin-bot

melvin-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown

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

@ShridharGoel ShridharGoel removed the request for review from thelullabyy June 20, 2026 18:46
@ShridharGoel ShridharGoel requested a review from mountiny June 20, 2026 18:48
@MelvinBot

Copy link
Copy Markdown
Contributor Author

🤖 I checked the CI status — all checks are now passing, so no fix is needed.

The only fail entry was a stale run of PR Author Checklist / checklist, which has since been re-run and passed (run 27880500350). Every other check (ESLint, Prettier, typecheck, all 8 test jobs, Bun tests, Storybook, builds, perf tests, spellcheck) is green.

The review check is still pending — that's the automated review bot and resolves on its own.

onBackButtonPress={() => Navigation.goBack(backPath)}
/>
{isLoadingFormDraft || shouldRedirectToCreatePage ? (
<FullScreenLoadingIndicator reasonAttributes={{context: 'DynamicReportFieldsInitialListValuePage', isLoadingFormDraft: !!isLoadingFormDraft}} />

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.

❌ UI-1 (docs)

FullScreenLoadingIndicator is rendered inside the same <ScreenWrapper> tree as the <HeaderWithBackButton> (lines 74-77). Because navigation (the back button) is visible alongside the loader, the user already has an escape route if loading hangs — so a full-screen loader is the wrong indicator here. This matches the UI-1 "Incorrect" example of FullscreenLoadingIndicator and HeaderWithBackButton living under the same JSX tree.

Use an ActivityIndicator centered in the content area instead, keeping the header rendered during loading:

{isLoadingFormDraft || shouldRedirectToCreatePage ? (
    <View style={[styles.flex1, styles.justifyContentCenter, styles.alignItemsCenter]}>
        <ActivityIndicator size={CONST.ACTIVITY_INDICATOR_SIZE.LARGE} />
    </View>
) : (
    // ...
)}

Reviewed at: 8ac54ef | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

// required error lingers. We can't detect the change by comparing the draft against `value` (they're already in
// sync by the time this runs), so we track the previous draft value and push it through onInputChange whenever it
// changes. onInputChange triggers the form's onValidate, which clears the stale error.
const previousDraftInitialValue = useRef(draftInitialValue);

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.

❌ PERF-10 (docs)

This useEffect exists solely to push a value up to the parent form via the onInputChange callback whenever the Onyx draft's initialValue changes. Using an effect to mirror state into a parent callback is the parent-communication anti-pattern PERF-10 targets — it adds an extra render pass, requires the manual useRef previous-value bookkeeping, and makes the data flow indirect.

Prefer having the parent (the create page / FormProvider) read the draft initialValue from Onyx directly and feed it into the form value, so the value flows down as a prop rather than being echoed back up from the child through an effect. That removes the need for this effect and the previousDraftInitialValue ref entirely.


Reviewed at: 8ac54ef | Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

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