Skip to content

fix: stabilize reopen ordering in basic pickers#85447

Open
marufsharifi wants to merge 11 commits intoExpensify:mainfrom
marufsharifi:fix/initial-selection-ordering-basic-pickers
Open

fix: stabilize reopen ordering in basic pickers#85447
marufsharifi wants to merge 11 commits intoExpensify:mainfrom
marufsharifi:fix/initial-selection-ordering-basic-pickers

Conversation

@marufsharifi
Copy link
Copy Markdown
Contributor

@marufsharifi marufsharifi commented Mar 16, 2026

Explanation of Change

Fixed Issues

$ #69184
PROPOSAL: #69184 (Comment)

Tests

Note: Below is just an example of one place this issue occurs. There are others, like the country list when adding a personal bank account to the Wallet. This PR fixes the bug on all relevant lists in the app at once.

  1. Go to Workspaces
  2. Go to Company cards
  3. Tap Add cards (opens country list)
  4. Verify that:
    • The selected item is at the very top
    • While selecting an item, it does not scroll
    • The selected item stays highlighted after clearing the search input
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests.

QA Steps

Same as Tests.

// TODO: These must be filled out, or the issue title must include "[No QA]."

  • 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

Record 1:

Screen.Recording.2026-03-30.at.7.24.01.PM.mov

Record 2:

Screen.Recording.2026-03-30.at.7.30.26.PM.mov

Record 3:

Screen.Recording.2026-03-30.at.7.24.55.PM.mov

Record 4:

Screen.Recording.2026-03-30.at.7.25.23.PM.mov

Record 5:

Screen.Recording.2026-03-30.at.7.26.39.PM.mov

Record 6:

Screen.Recording.2026-03-30.at.7.24.19.PM.mov

Record 8:

Screen.Recording.2026-03-30.at.7.27.10.PM.mov

Record 9:

Screen.Recording.2026-03-30.at.7.23.41.PM.mov

Record 10:

Screen.Recording.2026-04-01.at.3.13.33.PM.mov

Record 11:

Screen.Recording.2026-04-01.at.5.02.14.PM.mov

Record 12:

Screen.Recording.2026-04-01.at.5.03.25.PM.mov

Record 13:

Screen.Recording.2026-04-01.at.5.44.40.PM.mov

Record 14:

Screen.Recording.2026-04-01.at.5.45.11.PM.mov

Record 15:

Screen.Recording.2026-04-05.at.2.08.14.PM.mov

Record 16:

Screen.Recording.2026-04-05.at.2.13.16.PM.mov

Record 17:

Screen.Recording.2026-04-05.at.2.13.44.PM.mov

Record 18:

Screen.Recording.2026-04-05.at.2.14.28.PM.mov

Record 19:

Screen.Recording.2026-04-05.at.2.15.09.PM.mov

Record 20:

Screen.Recording.2026-04-05.at.2.17.19.PM.mov

Record 21:

Screen.Recording.2026-04-05.at.2.18.22.PM.mov

Record 22:

Screen.Recording.2026-04-05.at.2.22.26.PM.mov
Android: mWeb Chrome

Record 1:

Screen.Recording.2026-03-30.at.5.01.00.PM.mov

Record 2:

Screen.Recording.2026-03-30.at.5.03.08.PM.mov

Record 3:

Screen.Recording.2026-03-30.at.5.03.39.PM.mov

Record 4:

Screen.Recording.2026-03-30.at.5.13.30.PM.mov

Record 5:

Screen.Recording.2026-03-30.at.5.50.42.PM.mov

Record 6:

Screen.Recording.2026-03-30.at.4.55.18.PM.mov

Record 7:

Screen.Recording.2026-03-30.at.5.46.11.PM.mov

Record 8:

Screen.Recording.2026-03-30.at.4.54.08.PM.mov

Record 9:

Screen.Recording.2026-04-01.at.3.16.46.PM.mov

Record 10:

Screen.Recording.2026-04-01.at.3.17.57.PM.mov

Record 11:

Screen.Recording.2026-04-01.at.4.55.08.PM.mov

Record 12:

Screen.Recording.2026-04-01.at.4.57.46.PM.mov

Record 13:

Screen.Recording.2026-04-01.at.4.55.46.PM.mov

Record 14:

Screen.Recording.2026-04-01.at.4.58.45.PM.mov

Record 15:

Screen.Recording.2026-04-05.at.2.42.49.PM.mov

Record 16:

Screen.Recording.2026-04-05.at.3.02.24.PM.mov

Record 17:

Screen.Recording.2026-04-05.at.3.04.38.PM.mov

Record 18:

Screen.Recording.2026-04-05.at.3.05.12.PM.mov

Record 19:

Screen.Recording.2026-04-05.at.3.05.34.PM.mov

Record 20:

Screen.Recording.2026-04-05.at.3.06.56.PM.mov

Record 21:

Screen.Recording.2026-04-05.at.3.10.56.PM.mov

Record 22:

Screen.Recording.2026-04-05.at.3.11.45.PM.mov

Record 23:

Screen.Recording.2026-04-05.at.3.12.25.PM.mov
iOS: Native

Record 1:

Screen.Recording.2026-03-30.at.6.18.08.PM.mov

Record 2:

Screen.Recording.2026-03-30.at.6.18.31.PM.mov

Record 3:

Screen.Recording.2026-03-30.at.6.19.18.PM.mov

Record 4:

Screen.Recording.2026-03-30.at.6.20.11.PM.mov

Record 5:

Screen.Recording.2026-03-30.at.6.16.51.PM.mov

Record 6:

Screen.Recording.2026-03-30.at.6.20.53.PM.mov

Record 7:

Screen.Recording.2026-03-30.at.6.16.07.PM.mov

Record 8:

Screen.Recording.2026-04-01.at.11.33.09.AM.mov

Record 9:

Screen.Recording.2026-04-01.at.11.34.11.AM.mov

Record 10:

Screen.Recording.2026-04-01.at.11.35.50.AM.mov

Record 11:

Screen.Recording.2026-04-01.at.3.49.36.PM.mov

Record 12:

Screen.Recording.2026-04-01.at.3.53.02.PM.mov

Record 13:

Screen.Recording.2026-04-01.at.4.15.54.PM.mov

Record 14:

Screen.Recording.2026-04-01.at.4.16.47.PM.mov

Record 15:

Screen.Recording.2026-04-05.at.10.18.53.AM.mov

Record 16:

Screen.Recording.2026-04-05.at.11.00.26.AM.mov

Record 17:

Screen.Recording.2026-04-05.at.11.02.02.AM.mov

Record 18:

Screen.Recording.2026-04-05.at.11.02.53.AM.mov

Record 19:

Screen.Recording.2026-04-05.at.11.03.59.AM.mov

Record 20:

Screen.Recording.2026-04-05.at.11.05.48.AM.mov

Record 21:

Screen.Recording.2026-04-05.at.11.16.18.AM.mov

Record 22:

Screen.Recording.2026-04-05.at.12.22.30.PM.mov
iOS: mWeb Safari

Record 1:

Screen.Recording.2026-03-30.at.6.36.12.PM.mov

Record 2:

Screen.Recording.2026-03-30.at.6.36.51.PM.mov

Record 3:

Screen.Recording.2026-03-30.at.6.37.32.PM.mov

Record 4:

Screen.Recording.2026-03-30.at.6.36.33.PM.mov

Record 5:

Screen.Recording.2026-03-30.at.6.37.56.PM.mov

Record 6:

Screen.Recording.2026-03-30.at.6.38.40.PM.mov

Record 7:

Screen.Recording.2026-03-30.at.7.09.25.PM.mov

Record 8:

Screen.Recording.2026-03-30.at.7.14.01.PM.mov

Record 9:

Screen.Recording.2026-04-01.at.11.45.24.AM.mov

Record 10:

Screen.Recording.2026-04-01.at.11.46.41.AM.mov

Record 11:

Screen.Recording.2026-04-01.at.4.24.31.PM.mov

Record 12:

Screen.Recording.2026-04-01.at.4.25.32.PM.mov

Record 13:

Screen.Recording.2026-04-01.at.4.43.59.PM.mov

Record 14:

Screen.Recording.2026-04-05.at.11.53.14.AM.mov

Record 15:

Screen.Recording.2026-04-01.at.4.44.26.PM.mov

Record 16:

Screen.Recording.2026-04-05.at.11.55.14.AM.mov

Record 17:

Screen.Recording.2026-04-05.at.12.07.44.PM.mov

Record 18:

Screen.Recording.2026-04-05.at.12.08.31.PM.mov

Record 19:

Screen.Recording.2026-04-05.at.12.09.00.PM.mov

Record 20:

Screen.Recording.2026-04-05.at.12.09.16.PM.mov

Record 21:

Screen.Recording.2026-04-05.at.12.11.14.PM.mov

Record 22:

Screen.Recording.2026-04-05.at.12.13.37.PM.mov

Record 23:

Screen.Recording.2026-04-05.at.12.14.43.PM.mov
MacOS: Chrome / Safari

Record 1.

workspace.company.cards.add.card.feed.country.step.mov

Record 2.

settings.wallet.add.-.bank.account.account.detaisl.currencly.mov

Record 3.

Settings.Wallet.add.bank.account.bank.information.bank.region.mov

Record 4.

Settings.Wallet.add.bank.account.account.holder.detaisl.mov

Record 5.

create.expense.per.diem.subrate.mov

Record 6.

start.chat.roo.workspace.mov

Record 7.

start.chat.room.who.can.post.mov

Record 8.

only.available.by.route.copy.the.route.from.expensify.cards.mov

Record 9.

stat.chat.room.visibility.mov

Record 10.

expensify.card.issue.card.limit.type.mov

Record 11.

Expensify.card.card.item.Limit.Type.mov

Record 12.

create.expense.per.diem.add.subrate.then.update.that.subrate.mov

Record 13.

settings.profile.address.country.mov

Record 14.

Settings.profile.address.state.mov

Record 15.

Settings.Wallet.Add.bank.account.country.selection.mov

Record 16.

Screencast.From.2026-04-04.08-47-52.mp4

Record 17.

Screencast.From.2026-04-04.09-03-18.mp4

Record 18.

Screencast.From.2026-04-04.09-05-28.mp4

Record 19.

Screencast.From.2026-04-04.09-06-56.mp4

Record 20.

Screencast.From.2026-04-04.09-09-18.mp4

Record 21.

Screencast.From.2026-04-04.09-15-24.mp4

Record 22.

Screencast.From.2026-04-04.10-10-40.mp4

Record 23.

Screencast.From.2026-04-04.10-45-51.mp4

Record 24:

Screencast.From.2026-04-05.07-53-13.mp4

@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Mar 16, 2026

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

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2026

Codecov Report

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

Files with missing lines Coverage Δ
src/CONST/index.ts 93.65% <ø> (ø)
.../components/CountryPicker/CountrySelectorModal.tsx 100.00% <100.00%> (+100.00%) ⬆️
src/components/PushRowWithModal/PushRowModal.tsx 100.00% <100.00%> (+100.00%) ⬆️
src/components/SelectionList/BaseSelectionList.tsx 65.61% <100.00%> (+0.15%) ⬆️
src/components/StatePicker/StateSelectorModal.tsx 100.00% <100.00%> (+100.00%) ⬆️
src/components/ValuePicker/ValueSelectionList.tsx 100.00% <100.00%> (+100.00%) ⬆️
src/components/ValuePicker/ValueSelectorModal.tsx 100.00% <ø> (+100.00%) ⬆️
...le/PersonalDetails/DynamicCountrySelectionPage.tsx 93.75% <100.00%> (+93.75%) ⬆️
...ngs/Profile/PersonalDetails/StateSelectionPage.tsx 76.19% <100.00%> (+76.19%) ⬆️
src/pages/settings/Wallet/CountrySelectionList.tsx 100.00% <100.00%> (+100.00%) ⬆️
... and 3 more
... and 21 files with indirect coverage changes

Copy link
Copy Markdown
Contributor

@linhvovan29546 linhvovan29546 left a comment

Choose a reason for hiding this comment

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

LGTM! Could you please prioritize this one so we can hopefully merge it today?

Copy link
Copy Markdown
Contributor

@linhvovan29546 linhvovan29546 left a comment

Choose a reason for hiding this comment

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

@marufsharifi Could you also apply this change to the DynamicCountrySelectionPage, StateSelectionPage, CountrySelectionList and CountrySelection component?

@linhvovan29546
Copy link
Copy Markdown
Contributor

Bug: After removing/clearing the search, the selected item is no longer highlighted.

Screen.Recording.2026-03-17.at.16.10.56.mov

@linhvovan29546
Copy link
Copy Markdown
Contributor

Bug: After clearing the search, the selection list automatically scrolls

Screen.Recording.2026-03-17.at.16.12.03.mov

@marufsharifi
Copy link
Copy Markdown
Contributor Author

Sorry for the delay i was OOO, i will update here today. Thanks.

@marufsharifi marufsharifi marked this pull request as ready for review March 30, 2026 03:21
@marufsharifi marufsharifi requested review from a team as code owners March 30, 2026 03:21
@melvin-bot melvin-bot bot requested review from linhvovan29546 and removed request for a team March 30, 2026 03:21
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Mar 30, 2026

@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 trjExpensify and removed request for a team March 30, 2026 03:21
…allers

Rename useInitialSelectionRef to useInitialSelection to match its reactive
state return value, add a clarifying comment about why the snapshot only
resets on open/focus boundaries, and switch the current single-selection
picker callers to pass scalar values instead of string arrays.
Pass the debounced search value into SelectionList focus synchronization for
the basic picker flows so search-clear transitions use the same state that
drives the rendered data.
@marufsharifi
Copy link
Copy Markdown
Contributor Author

Bug: After removing/clearing the search, the selected item is no longer highlighted.

Screen.Recording.2026-03-17.at.16.10.56.mov

Fixed.

Root cause was that the picker data was driven by debouncedSearchValue, but the shared SelectionList focus-sync logic was still reacting to the live input value. During search clear, that mismatch could drop focus before the full list had actually returned, which made the selected row stop looking highlighted even though it was still selected.

I updated the affected first-PR pickers to pass the debounced search value into the shared focus-sync path, and added a focused regression test around useSearchFocusSync.

@marufsharifi
Copy link
Copy Markdown
Contributor Author

Bug: After clearing the search, the selection list automatically scrolls

Screen.Recording.2026-03-17.at.16.12.03.mov

Also fixed.

This turned out to have the same root cause as the first regression. The picker data was built from debouncedSearchValue, while the shared focus-sync logic was still reacting to the live input value. When clearing search one character at a time and waiting after each step, focus/scroll updates could run against stale filtered data before the full list had actually returned, which caused the visible jump.

Aligning the focus-sync path with the debounced search state fixed that transition as well.

… flows

Apply the initial-selection snapshot and reopen-only ordering behavior to
the dynamic profile country/state pickers and the shared wallet country
selection list. Search results now keep their natural filtered order while
focus sync follows the debounced search value, and the wallet country list
matches the no-focus-scroll behavior used in the first picker slice.
Keep the pre-existing memoization already present on main, but avoid the new
manual useMemo patterns introduced in this picker-ordering work where they
are not needed.
Include `isSelected` on the base country options used by
`SelectCountryStep` so the reordered and searched lists satisfy the shared
`searchOptions` option shape, and update the test to select a real rendered
row instead of constructing a narrower list item.
@marufsharifi
Copy link
Copy Markdown
Contributor Author

@linhvovan29546, sorry for the delay. I've addressed all your comments, and I am completing the PR Author checklist. You can continue your review. thanks.

Copy link
Copy Markdown
Contributor

@trjExpensify trjExpensify left a comment

Choose a reason for hiding this comment

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

Please add tests. Also, CC: @Expensify/design as I think ya'll will want eyes on this one!

@dubielzyk-expensify
Copy link
Copy Markdown
Contributor

I like the interaction in the video

@linhvovan29546
Copy link
Copy Markdown
Contributor

linhvovan29546 commented Mar 31, 2026

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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • 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 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)
  • 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
  • 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.
  • 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.
  • 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
Screen.Recording.2026-03-31.at.14.22.35.mov
Android: mWeb Chrome
Screen.Recording.2026-03-31.at.14.20.36.mov
iOS: HybridApp
Screen.Recording.2026-03-31.at.14.18.48.mov
iOS: mWeb Safari
Screen.Recording.2026-03-31.at.14.16.49.mov
MacOS: Chrome / Safari
Screen.Recording.2026-03-30.at.22.01.48.mov

@linhvovan29546
Copy link
Copy Markdown
Contributor

@marufsharifi Please add the test steps and QA steps

@shawnborton
Copy link
Copy Markdown
Contributor

Yeah same, feeling good to me too! Goodbye to all those annoying page jumps, finally!

@melvin-bot melvin-bot bot requested a review from srikarparsi March 31, 2026 07:25
@marufsharifi
Copy link
Copy Markdown
Contributor Author

I am still testing; it needs more testing on all platforms. @srikarparsi, you can review the codes, but please wait until I finish testing, then merge. thanks.

@srikarparsi
Copy link
Copy Markdown
Contributor

@MelvinBot can you please review this PR

@MelvinBot
Copy link
Copy Markdown
Contributor

Overall this is a well-structured PR. The useInitialSelection hook, SelectionListOrderUtils, and searchValueForFocusSync prop compose nicely to solve the ordering problem across all picker components. Tests are thorough. A few items:

1. initialSelectedValues defeats useMemo in ValueSelectionList

In ValueSelectionList.tsx, initialSelectedValues is a new array reference every render:

const initialSelectedValues = initialSelectedValue ? [initialSelectedValue] : [];
// ...
const options = useMemo(() => { ... }, [initialSelectedValues, items, selectedItem?.value]);

Since [initialSelectedValue] creates a fresh array each render, useMemo will always recompute (arrays are compared by reference). Consider memoizing this, e.g.:

const initialSelectedValues = useMemo(() => (initialSelectedValue ? [initialSelectedValue] : []), [initialSelectedValue]);

The same pattern exists in the other picker components (CountrySelectorModal, PushRowModal, etc.), but there initialSelectedValues is used in direct calls rather than useMemo deps, so it's less impactful — still worth making consistent though.

2. moveInitialSelectionToTopByKey is exported but unused

moveInitialSelectionToTopByKey in SelectionListOrderUtils.ts is only referenced in the unit test. If it's intended for future use, that's fine — just flagging it.

3. Minor: shouldSyncSelection / isEqual options are unused

useInitialSelection accepts shouldSyncSelection and isEqual options, but no caller uses them in this PR. If these are for a known upcoming use case, fine to keep. Otherwise they add surface area to the hook API that isn't exercised.

Everything else looks good — the debounced search value decoupling via searchValueForFocusSync, the threshold-gated reordering, and the focus sync test coverage are all solid.

@linhvovan29546
Copy link
Copy Markdown
Contributor

@marufsharifi Any updates? I don’t see the issue on my end.

@marufsharifi
Copy link
Copy Markdown
Contributor Author

@linhvovan29546, I've finished testing. I will check the latest comment. and finalize today. thanks.

Avoid rebuilding `ValueSelectionList` options on every render by depending on
the scalar initial selection value instead of a freshly created array, and
trim the unused `shouldSyncSelection` / `isEqual` options from
`useInitialSelection`.
@marufsharifi
Copy link
Copy Markdown
Contributor Author

@srikarparsi, I've addressed all the comments and finished testing on all platforms. Could you please take another look? thanks.

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.

7 participants