Skip to content

Fix/move preselected items to top#80322

Closed
marufsharifi wants to merge 51 commits intoExpensify:mainfrom
marufsharifi:fix/move-preselected-items-to-top
Closed

Fix/move preselected items to top#80322
marufsharifi wants to merge 51 commits intoExpensify:mainfrom
marufsharifi:fix/move-preselected-items-to-top

Conversation

@marufsharifi
Copy link
Copy Markdown
Contributor

@marufsharifi marufsharifi commented Jan 23, 2026

Explanation of Change

This will fix the behavior of jumping the lists. When the user selects/deselects, it shouldn't jump. However, when it goes away and comes back, the selected items should be at the very top.

Fixed Issues

$ #69184
PROPOSAL: #69184 (comment)

Tests

  1. Create a workspace
  2. Go to Company cards
  3. Click Add Card
  4. Select/deselect a new Country
  5. The selected item should stay in its place, and the list shouldn't jump.
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

1. Workspace > Members > Invite new members.

1-v.mp4

2. Workspace > Workflows > Approvals > Approver > set Approver.

Screen.Recording.2026-03-10.at.1.38.17.PM.mov

3. Workspace Chat > Chat Details > Members > Invite New Members.

3-v.mp4

4. Workspace > Company Cards > Add Card

Screen.Recording.1404-10-28.at.6.15.28.PM.mov

5. Reports > Search Drop downs > Timezones

Screen.Recording.1404-10-28.at.6.56.03.PM.mov

6. Reports > Filters > Workspace

Screen.Recording.1404-10-28.at.7.12.22.PM.mov

7. Reports > Filters > Purchase currency

Screen.Recording.1404-10-28.at.7.29.56.PM.mov

8. Reports > Filters > Currency

Screen.Recording.1404-10-28.at.7.30.38.PM.mov

9. Reports > Filters > Category

Screen.Recording.1404-10-28.at.7.32.24.PM.mov

10. Reports > Filters > From

Screen.Recording.1404-10-28.at.7.37.30.PM.mov

11. Reports > Filters > To

Screen.Recording.1404-10-28.at.7.38.17.PM.mov

12. Workspace > Overview > Default Currency

Screen.Recording.1404-10-28.at.7.57.06.PM.mov

13. Expense details > Amount (tag value)

Screen.Recording.1404-10-28.at.8.07.01.PM.mov

14. Expense details > attendees.

Screen.Recording.1404-11-05.at.12.25.51.PM.mp4

15. Workspace > expensify card > state

Screen.Recording.1404-11-05.at.10.34.22.AM.mov

16. Workspace > workflows > payment account > State

Screen.Recording.1404-11-05.at.10.36.19.AM.mov

17. Profile > Address > Country

Screen.Recording.1404-11-05.at.10.50.14.AM.mov

18. Subscriptions > Add payment card > Currency

Screen.Recording.1404-11-05.at.10.52.08.AM.mov

19. Preferences > Payment Currency

Screen.Recording.1404-11-05.at.10.53.19.AM.mov

20. Reports > Search Drop downs > Workspace

Screen.Recording.1404-11-05.at.12.45.14.PM.mov

21. Wallet > Add Bank account

Screen.Recording.1404-11-05.at.2.10.50.PM.mov

22. Wallet > Add Bank account > Currency

Screen.Recording.1404-11-05.at.2.11.27.PM.mov

23. Profile > Address > State

Screen.Recording.1404-11-05.at.2.13.03.PM.mov

24. Group Chat > Details > members > invite new members

Screen.Recording.1404-11-05.at.1.03.11.PM.mp4

25. Workspace > Workflows > Submissions > Frequency > Monthly > Date of Month

Screen.Recording.2026-03-10.at.1.54.17.PM.mov

26. Preferences > Language

Screen.Recording.1404-11-05.at.3.25.28.PM.mov

27. workflows > approvals > first approver > addetional approver

workflows.approvals.first.approver.addetional.approver.mov

28. workspace > per diem > currency

workspace.per.diem.currency.mov

29. workspace > New workspace > Default currency

add-workspace._.default.currency.mov

30. workspace chat > Create Expense > Select a currency

create.expense._.manual._.currency.mov

31. Chat Room > Debug-Report > currency

Screen.Recording.2026-03-10.at.11.42.52.AM.mov

32. Expense Details > Amount > currency

expense.details._.amont._.currency.mov

33. Workspace > Expensify Cards > Incorporation state

expensify.card._.incorporation.state.mov

34. FAB > Create Expense > Manual > To > Choose recipient

Screen.Recording.2026-03-10.at.1.59.57.PM.mov

35. Onboarding > Confirm workspace > Default Currency

onboarding._.workspace.currency.mov

36. Account > Expense Rules > Category

Screen.Recording.1404-11-19.at.9.37.45.AM.mov

37. Reports > Filters > Tag

Screen.Recording.1404-11-19.at.9.57.16.AM.mov

38. Account > Expense Rules > Tag

Screen.Recording.1404-11-20.at.3.05.38.PM.mov

39. Reports > Dates > On

Screen.Recording.1404-12-17.at.2.35.34.PM.mov

40. Workspace > Rules > Cash Expense Default

Screen.Recording.1404-12-17.at.3.07.25.AM.mov

41. Workspace > Rules > Billable Default

Screen.Recording.1404-12-17.at.3.08.04.AM.mov

42. Workspace > Rules > add merchant rule > category

Screen.Recording.1404-12-17.at.3.09.10.AM.mov

43. Workspace > Rules > add merchant rule > Reimbursable

Screen.Recording.1404-12-17.at.3.12.51.AM.mov

44. Workspace > Rules > Add Merchant Rule > Billable

Screen.Recording.1404-12-17.at.3.13.16.AM.mov

45. Workspace > Per Diem > more > Settings > Default Category

Screen.Recording.1404-12-17.at.3.14.14.AM.mov

46. Workspace > Distance Rate > Settings > Unit

Screen.Recording.1404-12-17.at.3.16.07.AM.mov

47. Workspace > Distance Rate > Settings > Default Category

Screen.Recording.1404-12-17.at.3.16.40.AM.mov

48. FAB > Create Expense > Per Diem

Screen.Recording.1404-12-17.at.3.21.03.AM.mov

49. Create Expense flow > amount > Select a currency

Screen.Recording.1404-12-17.at.3.22.08.AM.mov

50. Create Expense flow > Date > Year

Screen.Recording.2026-03-09.at.5.36.17.PM.mov

51. Create Expense flow > Subrate

Screen.Recording.2026-03-09.at.5.38.24.PM.mov

52. Reports > Filters > Approved > On > Year

Screen.Recording.1404-12-17.at.7.50.34.PM.mov

53. Reports > Filters > Date > On > Year

Screen.Recording.1404-12-17.at.7.53.09.PM.mov

54. Reports > Type, Status & Date

Screen.Recording.1404-12-17.at.7.59.07.PM.mov

55. Reports > Unappproved cash > Group by

Screen.Recording.1404-12-17.at.8.55.46.PM.mov

56. Chat Room > Debug Report > lastactiontype

Screen.Recording.1404-12-17.at.9.18.41.PM.mov

57. Chat Room > Debug Report > Chat type

Screen.Recording.1404-12-17.at.9.17.41.PM.mov

59. FAB > send invoice > Select a currency

Screen.Recording.1404-12-17.at.9.23.35.PM.mov

60. FAB > send invoice > To

Screen.Recording.1404-12-17.at.10.07.58.PM.mp4

61. FAB > send invoice > Date > Year

Screen.Recording.1404-12-17.at.10.09.38.PM.mov

62. Chat room > split expense > select a currency

Screen.Recording.1404-12-17.at.10.29.58.PM.mov

63. Chat room > Assign task > Assignee

Screen.Recording.2026-03-10.at.2.14.48.PM.mp4

64. Chat room > Assign task flow > Assignee

Screen.Recording.1404-12-17.at.10.53.44.PM.mov

65. Workspace chat> Per diem > Date > Year

Screen.Recording.1404-12-17.at.12.31.58.PM.mov

66. Workspace > Company Cards > Custom day of month > Custom close date

Screen.Recording.1404-12-18.at.12.12.31.AM.mov

67. Reports > Filters > assignee

search._.filters._.assignee.mov

68. Reports > Filters > Tax rate

Screen.Recording.2026-03-10.at.2.26.25.PM.mov

69. Reports > Filters > Attendees

search.page._.filters._.attendees.mov

70. FAB > Start Chat

Screen.Recording.2026-03-09.at.9.29.07.PM.mov

71. Expense Rule > Add Rule > Tax

Screen.Recording.2026-03-10.at.2.34.29.PM.mov

72. Workspaces > Taxes > Settings > Workspace Currency Default

Screen.Recording.2026-03-09.at.9.40.58.PM.mov

73. Workspaces > Taxes > Settings > Foreign Currency Default

Screen.Recording.2026-03-10.at.3.18.40.PM.mov

74. Profile > Date of Birth > Year

profile.dob.mov

75. Workspace > Rules > Add merchant rule > Destination

Screen.Recording.1404-12-17.at.3.09.43.AM.mov

76. Workspace > Rules > Add merchant rule > Subrate

Screen.Recording.1404-12-17.at.3.10.21.AM.mov

77. Workspace > Rules > Add merchant rule > Amount

Screen.Recording.1404-12-17.at.3.11.36.AM.mov

78. Workspace > Company Cards > add cards (add two cards) > Search Drop down

Screen.Recording.1404-12-18.at.12.15.04.AM.mov

@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Jan 23, 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 January 23, 2026 09:41
@melvin-bot
Copy link
Copy Markdown

melvin-bot bot commented Jan 23, 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 removed the request for review from a team January 23, 2026 09:41
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: 05b55479e2

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 23, 2026

Codecov Report

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

Files with missing lines Coverage Δ
src/CONST/index.ts 93.54% <ø> (ø)
src/components/Rule/RuleSelectionPicker.tsx 100.00% <100.00%> (ø)
src/components/Rule/hooks/useRuleSelectionList.ts 100.00% <100.00%> (ø)
...mponents/Search/FilterDropdowns/DropdownButton.tsx 92.59% <100.00%> (ø)
...onents/Search/FilterDropdowns/MultiSelectPopup.tsx 96.87% <100.00%> (+96.87%) ⬆️
...nents/Search/FilterDropdowns/SingleSelectPopup.tsx 96.87% <100.00%> (+96.87%) ⬆️
...c/components/Search/SearchFiltersChatsSelector.tsx 0.00% <ø> (ø)
...Search/SearchPageHeader/MultiSelectFilterPopup.tsx 0.00% <ø> (ø)
...ts/Search/SearchPageHeader/useSearchFiltersBar.tsx 78.12% <ø> (+3.12%) ⬆️
...components/SelectionList/ListItem/BaseListItem.tsx 96.22% <100.00%> (ø)
... and 60 more
... and 29 files with indirect coverage changes

@trjExpensify trjExpensify requested a review from a team January 23, 2026 12:29
trjExpensify
trjExpensify previously approved these changes Jan 23, 2026
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.

Agreed change with @Expensify/design team! Tagging 'em in though, if they want to check it out. 👍

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 I’ll continue the review after you address the feedback from the AI reviewer.

@shawnborton
Copy link
Copy Markdown
Contributor

Been a while for this one!

I also thought we wanted to make sure all selected items would be at the top of the list if they were already selected before opening up the list? Does that sound familiar? Pretty sure we had asked for that a while ago, but I'm not sure where we stand there.

@linhvovan29546
Copy link
Copy Markdown
Contributor

Pretty sure we had asked for that a while ago

The previous PR took a long time, and the contributor couldn’t find a working solution after the selection list refactor, so we’re reopening proposals.

@linhvovan29546
Copy link
Copy Markdown
Contributor

@linhvovan29546, could you please continue your review here? I am testing this everywhere. thanks.

Thanks for the hard work!
This is a pretty big PR with lots of changes, I’ll take a look and review it

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: a1194a3c94

ℹ️ 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".

@marufsharifi
Copy link
Copy Markdown
Contributor Author

@linhvovan29546, thanks for the review. I've addressed your comments; please take another look.

@JmillsExpensify
Copy link
Copy Markdown
Contributor

Great momentum. Would love to get this one merged this week.

@linhvovan29546
Copy link
Copy Markdown
Contributor

@codex review

@linhvovan29546
Copy link
Copy Markdown
Contributor

Reviewing...

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: ba473bb84a

ℹ️ 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 on lines +374 to +375
const selectedSectionBaseData = searchTerm.trim().length === 0 && initialSelectedOptions.length > 0 ? initialSelectedOptions : formattedSelectedOptions;
const selectedSectionData =
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 Keep newly selected participants visible in split selector

When this screen has preselected participants and the search box is empty, selectedSectionBaseData is pinned to initialSelectedOptions, so participants selected during the current interaction are not added to the selected section. The lower sections are built from availableOptions, which already excludes selected rows, so newly selected participants disappear from the list entirely (until search text is entered), making them hard to review or unselect before submitting.

Useful? React with 👍 / 👎.

);

const orderedOptions = useMemo(() => {
const shouldReorderInitialSelection = initialSelectedValues.length > 0 && options.length > CONST.MOVE_SELECTED_ITEMS_TO_TOP_OF_LIST_THRESHOLD;
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.

The moveInitialSelectionToTopByValue already handles shouldReorderInitialSelection itself.

 if (initialSelectedValues.length === 0 || items.length <= CONST.MOVE_SELECTED_ITEMS_TO_TOP_OF_LIST_THRESHOLD) {
        return items;
    }

So I think this is unnecessary. Could you please remove it here and in the other place(s) too?

* Reorders items that contain a `value` field by moving the initially selected values to the top.
* Preserves the original ordering within the selected and remaining groups.
*/
function moveInitialSelectionToTopByValue<T extends {value: string}>(items: T[], initialSelectedValues: string[]): T[] {
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.

This function uses 4 loops to reorder the items.
Why do we need 4 separate loops instead of doing it in just one loop like this?

function moveInitialSelectionToTopByValue<T extends {value: string}>(items: T[], initialSelectedValues: string[]): T[] {
    if (initialSelectedValues.length === 0 || items.length <= CONST.MOVE_SELECTED_ITEMS_TO_TOP_OF_LIST_THRESHOLD) {
        return items;
    }

    const initialSelectionSet = new Set(initialSelectedValues);
    const selected: T[] = [];
    const unselected: T[] = [];

    for (const item of items) {
        if (initialSelectionSet.has(item.value)) {
            selected.push(item);
            continue;
        }
        unselected.push(item);
    }

    return [...selected, ...unselected];
}

Same issue for reorderItemsByInitialSelection

if (initiallySelectedCurrencyCode) {
codes.add(initiallySelectedCurrencyCode);
}
for (const currencyCode of selectedCurrencies) {
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.

NAB: selectedCurrencies is no longer used, so we can safely remove this prop and all related logic

const isEmpty = searchValue.trim() && !filteredCurrencies.length;
const shouldReorderInitialSelection = !searchValue && initialSelectedCurrencySnapshot.length > 0;
const displayCurrencies = shouldReorderInitialSelection
? moveInitialSelectionToTopByValue(
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.

I think we can just use reorderItemsByInitialSelection instead of moveInitialSelectionToTopByValue. That way we don't need an extra .map() to create a new list

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.

Why do we need to modify this file? SearchAutocompleteList is an autocomplete/search router — not a selection list where users pick items that should stay pinned at the top.
There's no concept of "selected items" here that would benefit from reordering.

style={[
wrapperStyle,
isFocused &&
(!!isFocused || !!item.isSelected) &&
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.

onSelectRow={(option) => {
Keyboard.dismiss();
onYearChange?.(option.value);
onYearChange?.(Number(option.keyForList));
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.

Why do we need to update this?
I tried using option.value and it seems to work fine, no problems

ListItem={RadioListItem}
onSelectRow={(countryOption) => {
setSelectedCountry(countryOption.value ?? null);
setSelectedCountry(countryOption.keyForList?.toString() ?? null);
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.

Why do we need to update this?
I tried using option.value and it seems to work fine, no problems

return filteredDays;
}

return moveInitialSelectionToTopByValue(
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.

I think we can just use reorderItemsByInitialSelection instead of moveInitialSelectionToTopByValue. That way we don't need an extra .map() to create a new list

return mappedItems;
}

return moveInitialSelectionToTopByValue(mappedItems, initialSelectedValues);
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.

NAB: this re-render every time selectedItem changes

@linhvovan29546
Copy link
Copy Markdown
Contributor

linhvovan29546 commented Mar 10, 2026

@shawnborton @JmillsExpensify

This PR is quite large(Affects >100 files).
I suggest we split it into several smaller PRs.

Reasons:

  • Easier to review thoroughly
  • Lower risk when deploying to staging (big PRs often become deploy blockers, which can lead to reverts and we want to avoid reverts)
  • Incremental testing & rollout

Proposed split approach:

  1. First PR: move the "pre-selected item to top" logic into a common/shared place
    → affects these components:
    • CountrySelectorModal
    • StateSelectorModal
    • PushRowModal
    • ValueSelectionList / ValueSelectorModal
    • SelectCountryStep (company cards)

2–N. Later PRs: apply the shared logic to each specific flow

@JmillsExpensify Could you please confirm which place the user wants to go to fix for first one?

@JmillsExpensify
Copy link
Copy Markdown
Contributor

Defer to other reviews on splitting up the PR. As for this

Could you please confirm which place the user wants to go to fix for first one?

I don't think I understand the question. Can you ask it a different way?

@linhvovan29546
Copy link
Copy Markdown
Contributor

I don't think I understand the question. Can you ask it a different way?

@JmillsExpensify I just want to know where in the app the user is mentioned in this comment.
#80322 (comment)

@JmillsExpensify
Copy link
Copy Markdown
Contributor

I don't think I understand the question. Can you ask it a different way?

@JmillsExpensify I just want to know where in the app the user is mentioned in this comment. #80322 (comment)

Ah, I meant that our customer support team is getting feedback from customers that switching the selection around is confusing. It's just general product feedback.

@marufsharifi
Copy link
Copy Markdown
Contributor Author

@linhvovan29546, what is the final decision here? Should we continue this pr or create separate PRs? thanks.

@JmillsExpensify
Copy link
Copy Markdown
Contributor

Going with separate PRs makes sense to me. There are a lot of flows.

@marufsharifi
Copy link
Copy Markdown
Contributor Author

marufsharifi commented Mar 12, 2026

@linhvovan29546, could you please specify how many PRs we should have and which parts should go first? thanks.

@linhvovan29546
Copy link
Copy Markdown
Contributor

@linhvovan29546, could you please specify how many PRs we should have and which parts should go first? thanks.

I’m not sure exactly how many PRs we’ll end up with, but we can start with a low-risk, high-visibility first PR that implements the logic in these components:

  1. CountrySelectorModal
  2. StateSelectorModal
  3. PushRowModal
  4. ValueSelectionList / ValueSelectorModal
  5. SelectCountryStep (company cards)

@marufsharifi
Copy link
Copy Markdown
Contributor Author

@linhvovan29546, could you please specify how many PRs we should have and which parts should go first? thanks.

I’m not sure exactly how many PRs we’ll end up with, but we can start with a low-risk, high-visibility first PR that implements the logic in these components:

  1. CountrySelectorModal
  2. StateSelectorModal
  3. PushRowModal
  4. ValueSelectionList / ValueSelectorModal
  5. SelectCountryStep (company cards)

@linhvovan29546, thanks, the new pr will be ready tomorrow.

@linhvovan29546
Copy link
Copy Markdown
Contributor

@marufsharifi Is there any update on the new PR?

@marufsharifi
Copy link
Copy Markdown
Contributor Author

@linhvovan29546, I've resolved the conflicts. Here, I am working on a new PR. thanks. It will be ready today.

@marufsharifi
Copy link
Copy Markdown
Contributor Author

@linhvovan29546, I've created the first pr, but it is still in draft, since I am testing and creating records. Please feel free to review and give me your feedback. I will make it ready for review after finishing the checklist. thanks.

@linhvovan29546
Copy link
Copy Markdown
Contributor

@marufsharifi Could you please close this PR?

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