Skip to content

Conversation

@ChavdaSachin
Copy link
Contributor

@ChavdaSachin ChavdaSachin commented Jul 3, 2025

Explanation of Change

Fixed Issues

$ #61414
PROPOSAL: #61414 (comment)

Tests

Same as QA.

  • Verify that no errors appear in the JS console

Offline tests

Same as QA.

QA Steps

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

Search page:

  1. Go to reports > filters.
  2. Click filter Type > select Expense and save.
  3. Click From filter.
  4. Select a few items.
  5. Verify selected items does not move to top of the list.
  6. Click save
  7. Open the same filter again.
  8. Verify list has initial scroll position such as first selected item is visible.
  9. Select/deselect a few items.
  10. Verify list does not scroll on selecting/deselecting any item.
  11. For filters To, Workspace, Card, Category, Currency, Tag and Tax Rate repeat steps 4-10.
  12. Click filter Type > select Chat and save.
  13. For filter In repeat steps 4-10.
  14. Click filter Type > select Task and save.
  15. For filter Assignee repeat steps 4-10.

Group:

  1. Click FAB > start chat.
  2. Select a few users using Add to group button.
  3. Verify selected items does not move to top of the list and list does not scroll on selecting/deselecting any item.
  4. Click Next > Start Group.
  5. Click group header > Members > Invite members.
  6. Select/Deselect a few members.
  7. Verify selected member does not move to top of the list and list does not scroll on selecting/deselecting any member.

Room:

  1. Click FAB > Start chat > Room > create a room.
  2. Click room header > Members > Invite member.
  3. Select/Deselect a few members.
  4. Verify selected member does not move to top of the list and list does not scroll on selecting/deselecting any member.

Workspace: (create one if needed)

  1. Go to Workspaces > open a workspace.
  2. Go to Members > Invite Member.
  3. Select/Deselect a few members.
  4. Verify selected member does not move to top of the list and list does not scroll on selecting/deselecting any member.

IOU: (prerequisite: user has a control workspace set as the default workspace)

  1. Click FAB > Create expense > Manual.
  2. Enter amount and click Next.
  3. Click Attendees.
  4. Select/Deselect a few members.
  5. Verify selected member does not move to top of the list and list does not scroll on selecting/deselecting any member.
  6. Click Save.
  7. Again open Attendees.
  8. Verify list has initial scroll position such as first selected assignee is visible.

Onboarding:

  1. Create a new account.
  2. Skip Work Email step.
  3. Select Track and budget expenses on purpose select step.
  4. Enter First Name and Last Name, click continue.
  5. Click Create workspace > Continue.
  6. Search and select a few members.
  7. Verify selected member does not move to top of the list and list does not scroll on selecting/deselecting any member.
  • 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
    • MacOS: Desktop
  • 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 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
Screen.Recording.2025-09-02.at.12.27.48.PM.mov
Screen.Recording.2025-09-02.at.12.33.45.PM.mov
Screen.Recording.2025-09-02.at.12.35.00.PM.mov
Screen.Recording.2025-09-02.at.12.36.03.PM.mov
Screen.Recording.2025-09-02.at.12.36.42.PM.mov
Screen.Recording.2025-09-02.at.12.40.49.PM.mov
Android: mWeb Chrome
Screen.Recording.2025-09-02.at.12.47.53.PM.mov
Screen.Recording.2025-09-02.at.12.50.56.PM.mov
Screen.Recording.2025-09-02.at.12.51.41.PM.mov
Screen.Recording.2025-09-02.at.12.52.44.PM.mov
Screen.Recording.2025-09-02.at.12.53.13.PM.mov
Screen.Recording.2025-09-02.at.12.55.05.PM.mov
iOS: Native
Screen.Recording.2025-09-02.at.11.40.25.AM.mov
Screen.Recording.2025-09-02.at.11.46.32.AM.mov
Screen.Recording.2025-09-02.at.11.47.35.AM.mov
Screen.Recording.2025-09-02.at.11.48.58.AM.mov
Screen.Recording.2025-09-02.at.11.51.02.AM.mov
Screen.Recording.2025-09-02.at.11.57.32.AM.mov
iOS: mWeb Safari
Screen.Recording.2025-09-02.at.12.03.21.PM.mov
Screen.Recording.2025-09-02.at.12.07.41.PM.mov
Screen.Recording.2025-09-02.at.12.09.47.PM.mov
Screen.Recording.2025-09-02.at.12.11.30.PM.mov
Screen.Recording.2025-09-02.at.12.12.05.PM.mov
Screen.Recording.2025-09-02.at.12.16.08.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2025-08-31.at.7.03.14.PM.mov
Screen.Recording.2025-08-31.at.7.06.01.PM.mov
Screen.Recording.2025-08-31.at.7.07.00.PM.mov
Screen.Recording.2025-08-31.at.7.07.44.PM.mov
Screen.Recording.2025-08-31.at.7.08.24.PM.mov
Screen.Recording.2025-08-31.at.7.10.55.PM.mov
MacOS: Desktop
Screen.Recording.2025-09-02.at.1.17.37.PM.mov
Screen.Recording.2025-09-02.at.1.21.15.PM.mov
Screen.Recording.2025-09-02.at.1.23.15.PM.mov
Screen.Recording.2025-09-02.at.1.23.44.PM.mov
Screen.Recording.2025-09-02.at.1.24.13.PM.mov
Screen.Recording.2025-09-02.at.1.24.50.PM.mov

@ChavdaSachin
Copy link
Contributor Author

@parasharrajat

When we pass the first index using initiallyFocusedOptionKey prop, I could see a small visual inconsistency

  • when multiple items are selected this prop would highlight the first selected item and other selected items are not highlighted.

What is the expected behavior for the highlight for both single selection list and multi selection list?

Screen.Recording.2025-07-04.at.12.54.14.AM.mov
Basically after applying following diff suggested in original proposal
--- a/src/components/Search/SearchMultipleSelectionPicker.tsx
+++ b/src/components/Search/SearchMultipleSelectionPicker.tsx
@@ -8,6 +8,7 @@ import type {OptionData} from '@libs/ReportUtils';
 import {sortOptionsWithEmptyValue} from '@libs/SearchQueryUtils';
 import ROUTES from '@src/ROUTES';
 import SearchFilterPageFooterButtons from './SearchFilterPageFooterButtons';
+import SelectableListItem from '@components/SelectionList/SelectableListItem';
 
 type SearchMultipleSelectionPickerItem = {
     name: string;
@@ -32,35 +33,26 @@ function SearchMultipleSelectionPicker({items, initiallySelectedItem
s, pickerTit
         setSelectedItems(initiallySelectedItems ?? []);
     }, [initiallySelectedItems]);
 
-    const {sections, noResultsFound} = useMemo(() => {
-        const selectedItemsSection = selectedItems
-            .filter((item) => item?.name.toLowerCase().includes(debouncedSearchTerm?.to
LowerCase()))
-            .sort((a, b) => sortOptionsWithEmptyValue(a.value as string, b.value as str
ing))
-            .map((item) => ({
-                text: item.name,
-                keyForList: item.name,
-                isSelected: true,
-                value: item.value,
-            }));
+    const {sections, noResultsFound, firstKeyForList} = useMemo(() => {
         const remainingItemsSection = items
-            .filter((item) => selectedItems.some((selectedItem) => selectedItem.value =
== item.value) === false && item?.name?.toLowerCase().includes(debouncedSearchTerm?.toLo
werCase()))
-            .sort((a, b) => sortOptionsWithEmptyValue(a.value as string, b.value as str
ing))
+            .filter((item) => item?.name?.toLowerCase().includes(debouncedSearchTerm?.t
oLowerCase()))
+            .sort((a, b) => sortOptionsWithEmptyValue(a, b))
             .map((item) => ({
                 text: item.name,
                 keyForList: item.name,
-                isSelected: false,
+                isSelected: selectedItems.some((selectedItem) => selectedItem.value ===
 item.value),
                 value: item.value,
             }));
-        const isEmpty = !selectedItemsSection.length && !remainingItemsSection.length;
+
+        const isEmpty = !remainingItemsSection.length;
+
+        const firstSelectedItem = remainingItemsSection.find((item) => item.isSelected)
;
+        const firstKey = firstSelectedItem?.keyForList ?? null;
+
         return {
             sections: isEmpty
                 ? []
                 : [
-                      {
-                          title: undefined,
-                          data: selectedItemsSection,
-                          shouldShow: selectedItemsSection.length > 0,
-                      },
                       {
                           title: pickerTitle,
                           data: remainingItemsSection,
@@ -68,6 +60,7 @@ function SearchMultipleSelectionPicker({items, initiallySelectedItems,
 pickerTit
                       },
                   ],
             noResultsFound: isEmpty,
+            firstKeyForList: firstKey,
         };
     }, [selectedItems, items, pickerTitle, debouncedSearchTerm]);
 
@@ -116,7 +109,8 @@ function SearchMultipleSelectionPicker({items, initiallySelectedItem
s, pickerTit
             showLoadingPlaceholder={!noResultsFound}
             shouldShowTooltips
             canSelectMultiple
-            ListItem={MultiSelectListItem}
+            ListItem={SelectableListItem}
+            initiallyFocusedOptionKey={firstKeyForList}
         />
     );
 }

@ChavdaSachin
Copy link
Contributor Author

@parasharrajat waiting for your reply to proceed further...

@parasharrajat
Copy link
Member

Let's update this behaviour in a way so that it does not highlight. We are only using this prop to scroll to the item.

@ChavdaSachin
Copy link
Contributor Author

For a single selection list, Should we highlight?

@parasharrajat
Copy link
Member

When the user is using arrow keys to navigate, it makes sense to have highlight to show the active item in the list but otherwise, I don't the point of highlight.

@shawnborton Can you please help us determine whether we should highlight the row or not?

@shawnborton
Copy link
Contributor

Hmm why would we change any of the current arrow behavior here? We should just continue to use the existing arrow highlight behavior that we currently have, no? cc @Expensify/design for a gut check.

@ChavdaSachin
Copy link
Contributor Author

I am not asking about the arrows, I am asking about background colour

@shawnborton
Copy link
Contributor

Yeah same thing, why would we change any of that behavior? We should leave it as-is.

@dannymcclain
Copy link
Contributor

Agree with Shawn, I don't see why we'd need to mess with any of that here.

@ChavdaSachin ChavdaSachin force-pushed the fix-61414/stop-scrolling-and-jumping-selectionList branch from c5fb170 to 1bf1112 Compare July 23, 2025 16:35
@ChavdaSachin
Copy link
Contributor Author

@parasharrajat are we looking to apply these changes to popover filters as well?

Screen.Recording.2025-07-23.at.10.08.21.PM.mov

@parasharrajat
Copy link
Member

parasharrajat commented Jul 24, 2025

Let's not do that for now. If needed we can do that in separate PR.

@ChavdaSachin
Copy link
Contributor Author

ChavdaSachin commented Jul 24, 2025

Actually From and To advanced filters also use the same hook useSearchParticipantsOptions along with this popover to separate the sections (keeps selected options on top), so keeping it separate would require more complex modification of the hook.

@parasharrajat
Copy link
Member

Let's keep such pages aside for now. Focus on other SelectionList-based logic. Once you are done, you can list down such pages for us and then we can tackle then in separate PR.

@parasharrajat
Copy link
Member

@ChavdaSachin What's latest here?

@ChavdaSachin
Copy link
Contributor Author

Most of the pages which are yet to be fixed are related to member lists, and since member lists have quite a complex structure it is taking some time.
I would try to wrap it up in a day or two.

@parasharrajat
Copy link
Member

If you don't have time to work on this. Let me us know the progress and pending items so we can decide on next steps here.

@ChavdaSachin
Copy link
Contributor Author

Note: MoneyRequestParticipantsSelector hasn't been refactored in this PR.

Reason: Split expense flow has been removed from the app, so it is not possible for value of canSelectMultiple to be true on this particular page.

all the other pages where canSelectMultiple = true are refactored.

cc. @parasharrajat

ps. Contributor who worked on removing split expense flow should refactor all such pages.

@ChavdaSachin
Copy link
Contributor Author

ChavdaSachin commented Aug 28, 2025

Tests:

Search page:

  1. Go to reports > filters.
  2. Click filter Type > select Expense and save.
  3. Click From filter.
  4. Select a few items.
  5. Verify selected items does not move to top of the list.
  6. Click save
  7. Open the same filter again.
  8. Verify list has initial scroll position such as first selected item is visible.
  9. Select/deselect a few items.
  10. Verify list does not scroll on selecting/deselecting any item.
  11. For filters To, Workspace, Card, Category, Currency, Tag and Tax Rate repeat steps 4-10.
  12. Click filter Type > select Chat and save.
  13. For filter In repeat steps 4-10.
  14. Click filter Type > select Task and save.
  15. For filter Assignee repeat steps 4-10.

Group:

  1. Click FAB > start chat.
  2. Select a few users using Add to group button.
  3. Verify selected items does not move to top of the list and list does not scroll on selecting/deselecting any item.
  4. Click Next > Start Group.
  5. Click group header > Members > Invite members.
  6. Select/Deselect a few members.
  7. Verify selected member does not move to top of the list and list does not scroll on selecting/deselecting any member.

Room:

  1. Click FAB > Start chat > Room > create a room.
  2. Click room header > Members > Invite member.
  3. Select/Deselect a few members.
  4. Verify selected member does not move to top of the list and list does not scroll on selecting/deselecting any member.

Workspace: (create one if needed)

  1. Go to Workspaces > open a workspace.
  2. Go to Members > Invite Member.
  3. Select/Deselect a few members.
  4. Verify selected member does not move to top of the list and list does not scroll on selecting/deselecting any member.

IOU: (prerequisite: user has a control workspace set as the default workspace)

  1. Click FAB > Create expense > Manual.
  2. Enter amount and click Next.
  3. Click Attendees.
  4. Select/Deselect a few members.
  5. Verify selected member does not move to top of the list and list does not scroll on selecting/deselecting any member.
  6. Click Save.
  7. Again open Attendees.
  8. Verify list has initial scroll position such as first selected assignee is visible.

Onboarding:

  1. Create a new account.
  2. Skip Work Email step.
  3. Select Track and budget expenses on purpose select step.
  4. Enter First Name and Last Name, click continue.
  5. Click Create workspace > Continue.
  6. Search and select a few members.
  7. Verify selected member does not move to top of the list and list does not scroll on selecting/deselecting any member.

@ChavdaSachin

This comment was marked as resolved.

@ChavdaSachin

This comment was marked as resolved.

@ChavdaSachin

This comment was marked as resolved.

@ChavdaSachin ChavdaSachin marked this pull request as ready for review September 2, 2025 08:18
@ChavdaSachin ChavdaSachin requested review from a team as code owners September 2, 2025 08:18
@melvin-bot melvin-bot bot requested review from parasharrajat and removed request for a team September 2, 2025 08:18
@melvin-bot
Copy link

melvin-bot bot commented Sep 2, 2025

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

@parasharrajat
Copy link
Member

@ChavdaSachin Can you please merge main?

@ChavdaSachin
Copy link
Contributor Author

Sure thing, I am ooo today and tomorrow, I should be able to work it out on Tuesday.

@ChavdaSachin
Copy link
Contributor Author

@parasharrajat I could see there are far too many changes which could be resolved here.
And I could see another refactor issue which would keep conflicting with current issue.
I think we need to close the current PR and and hold on for refactor issue subtasks (should be merged within current week) and then raise a brand new PR.
In the mean time I could raise a PR for simpler single selection lists where getValidOptions or useSearchSelector hooks are irrelevant.
agree?

Copy link
Contributor

@JmillsExpensify JmillsExpensify left a comment

Choose a reason for hiding this comment

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

Love the product changes happening in this PR.

@parasharrajat
Copy link
Member

@ChavdaSachin Looks like the PR you tagged is merged. What is your new plan?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants