From 3db6420321937023bf5a0ca73d34cf8fcad06b57 Mon Sep 17 00:00:00 2001 From: Zuzanna Furtak Date: Mon, 9 Feb 2026 12:48:28 +0100 Subject: [PATCH 1/4] Make MoneyRequestAttendeeSelector use new SelectionList --- .../SelectionList/components/TextInput.tsx | 3 +- src/components/SelectionList/types.ts | 3 ++ .../BaseTextInput/implementation/index.tsx | 3 ++ .../request/MoneyRequestAttendeeSelector.tsx | 52 +++++++++++-------- 4 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/components/SelectionList/components/TextInput.tsx b/src/components/SelectionList/components/TextInput.tsx index ae4e2548541a..42e39a5514ee 100644 --- a/src/components/SelectionList/components/TextInput.tsx +++ b/src/components/SelectionList/components/TextInput.tsx @@ -65,7 +65,7 @@ function TextInput({ }: TextInputProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const {label, value, onChangeText, errorText, headerMessage, hint, disableAutoFocus, placeholder, maxLength, inputMode, ref: optionsRef, style} = options ?? {}; + const {label, value, onChangeText, errorText, headerMessage, hint, disableAutoFocus, placeholder, maxLength, inputMode, ref: optionsRef, style, disableAutoCorrect} = options ?? {}; const resultsFound = headerMessage !== translate('common.noResultsFound'); const noData = dataLength === 0 && !showLoadingPlaceholder; const shouldShowHeaderMessage = !!headerMessage && (!isLoadingNewOptions || resultsFound || noData); @@ -135,6 +135,7 @@ function TextInput({ testID="selection-list-text-input" errorText={errorText} shouldInterceptSwipe={false} + autoCorrect={!disableAutoCorrect} /> {shouldShowHeaderMessage && ( diff --git a/src/components/SelectionList/types.ts b/src/components/SelectionList/types.ts index a0fdad86bf3f..2c7aaa5f81da 100644 --- a/src/components/SelectionList/types.ts +++ b/src/components/SelectionList/types.ts @@ -235,6 +235,9 @@ type TextInputOptions = { /** Whether the text input autofocus should be disabled */ disableAutoFocus?: boolean; + /** Whether the text input auto correct should be disabled */ + disableAutoCorrect?: boolean; + /** Styles for the text input */ style?: { /** Styles for the text input container */ diff --git a/src/components/TextInput/BaseTextInput/implementation/index.tsx b/src/components/TextInput/BaseTextInput/implementation/index.tsx index 6fc2988bee93..7fcf67f518b7 100644 --- a/src/components/TextInput/BaseTextInput/implementation/index.tsx +++ b/src/components/TextInput/BaseTextInput/implementation/index.tsx @@ -283,6 +283,9 @@ function BaseTextInput({ shouldAddPaddingBottom && styles.pb1, ]); + console.log('inputProps.secureTextEntry', inputProps.secureTextEntry); + console.log('autoCorrect', autoCorrect); + const verticalPaddingDiff = StyleUtils.getVerticalPaddingDiffFromStyle(newTextInputContainerStyles); const inputPaddingLeft = !!prefixCharacter && StyleUtils.getPaddingLeft(prefixCharacterPadding + styles.pl1.paddingLeft); const inputPaddingRight = !!suffixCharacter && StyleUtils.getPaddingRight(StyleUtils.getCharacterPadding(suffixCharacter) + styles.pr1.paddingRight); diff --git a/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx b/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx index ee83c80b547a..e7490036c3e3 100644 --- a/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx +++ b/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx @@ -6,10 +6,9 @@ import Button from '@components/Button'; import EmptySelectionListContent from '@components/EmptySelectionListContent'; import FormHelpMessage from '@components/FormHelpMessage'; import {usePersonalDetails} from '@components/OnyxListItemProvider'; -// eslint-disable-next-line no-restricted-imports -import SelectionList from '@components/SelectionListWithSections'; -import InviteMemberListItem from '@components/SelectionListWithSections/InviteMemberListItem'; -import type {SectionListDataType} from '@components/SelectionListWithSections/types'; +import InviteMemberListItem from '@components/SelectionList/ListItem/InviteMemberListItem'; +import SelectionListWithSections from '@components/SelectionList/SelectionListWithSections'; +import {Section} from '@components/SelectionList/SelectionListWithSections/types'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; @@ -37,6 +36,7 @@ import type {IOUAction, IOUType} from '@src/CONST'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Attendee} from '@src/types/onyx/IOU'; +import getEmptyArray from '@src/types/utils/getEmptyArray'; import SafeString from '@src/utils/SafeString'; type MoneyRequestAttendeesSelectorProps = { @@ -206,7 +206,7 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde * Returns the sections needed for the OptionsSelector */ const [sections, header] = useMemo(() => { - const newSections: Array> = []; + const newSections: Array> = []; if (!areOptionsInitialized || !didScreenTransitionEnd) { return [newSections, '']; } @@ -226,6 +226,7 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde newSections.push({ ...formatResults.section, + sectionIndex: 0, data: formatResults.section.data as OptionData[], }); @@ -233,6 +234,7 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde newSections.push({ title: translate('common.recents'), data: orderedAvailableOptions.recentReports, + sectionIndex: 1, }); } @@ -240,6 +242,7 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde newSections.push({ title: translate('common.contacts'), data: orderedAvailableOptions.personalDetails, + sectionIndex: 2, }); } @@ -263,7 +266,7 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde ? getPolicyExpenseReportOption(participant, currentUserAccountID, personalDetails, reportAttributesDerived) : getParticipantsOption(participant, personalDetails); }) as OptionData[], - shouldShow: true, + sectionIndex: 3, }); } @@ -303,27 +306,34 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde const shouldShowListEmptyContent = useMemo(() => optionLength === 0 && !showLoadingPlaceholder, [optionLength, showLoadingPlaceholder]); + const textInputOptions = { + label: translate('selectionList.nameEmailOrPhoneNumber'), + hint: offlineMessage, + value: searchTerm, + onChangeText: setSearchTerm, + headerMessage: header, + disableAutoCorrect: true, + }; + return ( - >()} ListItem={InviteMemberListItem} - textInputValue={searchTerm} - textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')} - textInputHint={offlineMessage} - onChangeText={setSearchTerm} - shouldPreventDefaultFocusOnSelectRow={!canUseTouchScreen()} onSelectRow={toggleSelection} - shouldSingleExecuteRowSelect + textInputOptions={textInputOptions} + confirmButtonOptions={{ + onConfirm: handleConfirmSelection, + }} footerContent={footerContent} - autoCorrect={false} - listEmptyContent={} - headerMessage={header} - showLoadingPlaceholder={showLoadingPlaceholder} - canSelectMultiple isLoadingNewOptions={!!isSearchingForReports} - shouldShowListEmptyContent={shouldShowListEmptyContent} + showLoadingPlaceholder={showLoadingPlaceholder} + showListEmptyContent={shouldShowListEmptyContent} + listEmptyContent={} + shouldPreventDefaultFocusOnSelectRow={!canUseTouchScreen()} onEndReached={onListEndReached} + shouldSingleExecuteRowSelect + shouldShowTextInput + canSelectMultiple /> ); } From 062116c82e622e3061fb80cef78c78c918c4a8ff Mon Sep 17 00:00:00 2001 From: Zuzanna Furtak Date: Mon, 9 Feb 2026 12:51:49 +0100 Subject: [PATCH 2/4] Remove console.logs --- .../TextInput/BaseTextInput/implementation/index.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/TextInput/BaseTextInput/implementation/index.tsx b/src/components/TextInput/BaseTextInput/implementation/index.tsx index 7fcf67f518b7..6fc2988bee93 100644 --- a/src/components/TextInput/BaseTextInput/implementation/index.tsx +++ b/src/components/TextInput/BaseTextInput/implementation/index.tsx @@ -283,9 +283,6 @@ function BaseTextInput({ shouldAddPaddingBottom && styles.pb1, ]); - console.log('inputProps.secureTextEntry', inputProps.secureTextEntry); - console.log('autoCorrect', autoCorrect); - const verticalPaddingDiff = StyleUtils.getVerticalPaddingDiffFromStyle(newTextInputContainerStyles); const inputPaddingLeft = !!prefixCharacter && StyleUtils.getPaddingLeft(prefixCharacterPadding + styles.pl1.paddingLeft); const inputPaddingRight = !!suffixCharacter && StyleUtils.getPaddingRight(StyleUtils.getCharacterPadding(suffixCharacter) + styles.pr1.paddingRight); From 1541910a7432b1a2602e0751fa375d463ce63ac4 Mon Sep 17 00:00:00 2001 From: Zuzanna Furtak Date: Mon, 9 Feb 2026 14:04:07 +0100 Subject: [PATCH 3/4] Remove manual memoization --- .../request/MoneyRequestAttendeeSelector.tsx | 122 ++++++------------ 1 file changed, 43 insertions(+), 79 deletions(-) diff --git a/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx b/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx index e7490036c3e3..fc41cf6ec80a 100644 --- a/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx +++ b/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx @@ -1,6 +1,6 @@ import reportsSelector from '@selectors/Attributes'; import {deepEqual} from 'fast-equals'; -import React, {memo, useCallback, useEffect, useMemo} from 'react'; +import React, {memo, useEffect} from 'react'; import type {GestureResponderEvent} from 'react-native'; import Button from '@components/Button'; import EmptySelectionListContent from '@components/EmptySelectionListContent'; @@ -8,7 +8,7 @@ import FormHelpMessage from '@components/FormHelpMessage'; import {usePersonalDetails} from '@components/OnyxListItemProvider'; import InviteMemberListItem from '@components/SelectionList/ListItem/InviteMemberListItem'; import SelectionListWithSections from '@components/SelectionList/SelectionListWithSections'; -import {Section} from '@components/SelectionList/SelectionListWithSections/types'; +import type {Section} from '@components/SelectionList/SelectionListWithSections/types'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; @@ -73,27 +73,19 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const currentUserEmail = currentUserPersonalDetails.email ?? ''; const currentUserAccountID = currentUserPersonalDetails.accountID; - - const isPaidGroupPolicy = useMemo(() => isPaidGroupPolicyFn(policy), [policy]); - - const recentAttendeeLists = useMemo( - () => getFilteredRecentAttendees(personalDetails, attendees, recentAttendees ?? [], currentUserEmail, currentUserAccountID), - [personalDetails, attendees, recentAttendees, currentUserEmail, currentUserAccountID], - ); - const initialSelectedOptions = useMemo( - () => - attendees.map((attendee) => ({ - ...attendee, - reportID: CONST.DEFAULT_NUMBER_ID.toString(), - keyForList: String(attendee.accountID) ?? (attendee.email || attendee.displayName), - selected: true, - // Use || to fall back to displayName for name-only attendees (empty email) - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - login: attendee.email || attendee.displayName, - ...getPersonalDetailByEmail(attendee.email), - })), - [attendees], - ); + const isPaidGroupPolicy = isPaidGroupPolicyFn(policy); + const recentAttendeeLists = getFilteredRecentAttendees(personalDetails, attendees, recentAttendees ?? [], currentUserEmail, currentUserAccountID); + + const initialSelectedOptions = attendees.map((attendee) => ({ + ...attendee, + reportID: CONST.DEFAULT_NUMBER_ID.toString(), + keyForList: String(attendee.accountID) ?? (attendee.email || attendee.displayName), + selected: true, + // Use || to fall back to displayName for name-only attendees (empty email) + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + login: attendee.email || attendee.displayName, + ...getPersonalDetailByEmail(attendee.email), + })); const {searchTerm, debouncedSearchTerm, setSearchTerm, availableOptions, selectedOptions, toggleSelection, areOptionsInitialized, onListEndReached} = useSearchSelector({ selectionMode: CONST.SEARCH_SELECTOR.SELECTION_MODE_MULTI, @@ -134,11 +126,10 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde searchInServer(debouncedSearchTerm.trim()); }, [debouncedSearchTerm]); - const orderedAvailableOptions = useMemo(() => { - if (!isPaidGroupPolicy || !areOptionsInitialized) { - return availableOptions; - } - + let orderedAvailableOptions; + if (!isPaidGroupPolicy || !areOptionsInitialized) { + orderedAvailableOptions = availableOptions; + } else { const orderedOptions = orderOptions( { recentReports: availableOptions.recentReports, @@ -152,31 +143,27 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde preferRecentExpenseReports: action === CONST.IOU.ACTION.CREATE, }, ); - - return { + orderedAvailableOptions = { ...availableOptions, recentReports: orderedOptions.recentReports, personalDetails: orderedOptions.personalDetails, workspaceChats: orderedOptions.workspaceChats, }; - }, [availableOptions, isPaidGroupPolicy, areOptionsInitialized, searchTerm, action]); + } const shouldShowErrorMessage = selectedOptions.length < 1; - const handleConfirmSelection = useCallback( - (_keyEvent?: GestureResponderEvent | KeyboardEvent, option?: OptionData) => { - if (shouldShowErrorMessage || (!selectedOptions.length && !option)) { - return; - } + const handleConfirmSelection = (_keyEvent?: GestureResponderEvent | KeyboardEvent, option?: OptionData) => { + if (shouldShowErrorMessage || (!selectedOptions.length && !option)) { + return; + } - onFinish(CONST.IOU.TYPE.SUBMIT); - }, - [shouldShowErrorMessage, onFinish, selectedOptions.length], - ); + onFinish(CONST.IOU.TYPE.SUBMIT); + }; - const showLoadingPlaceholder = useMemo(() => !areOptionsInitialized || !didScreenTransitionEnd, [areOptionsInitialized, didScreenTransitionEnd]); + const showLoadingPlaceholder = !areOptionsInitialized || !didScreenTransitionEnd; - const footerContent = useMemo(() => { + const getFooterContent = () => { if (!shouldShowErrorMessage && !selectedOptions.length) { return; } @@ -200,17 +187,16 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde /> ); - }, [handleConfirmSelection, selectedOptions.length, shouldShowErrorMessage, styles, translate]); - - /** - * Returns the sections needed for the OptionsSelector - */ - const [sections, header] = useMemo(() => { + }; + const footerContent = getFooterContent(); + + let sections: Array>; + let header: string; + if (!areOptionsInitialized || !didScreenTransitionEnd) { + sections = []; + header = ''; + } else { const newSections: Array> = []; - if (!areOptionsInitialized || !didScreenTransitionEnd) { - return [newSections, '']; - } - const cleanSearchTerm = searchTerm.trim().toLowerCase(); const formatResults = formatSectionsFromSearchTerm( cleanSearchTerm, @@ -270,41 +256,19 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde }); } - const headerMessage = getHeaderMessage( + header = getHeaderMessage( formatResults.section.data.length + (orderedAvailableOptions.personalDetails ?? []).length + (orderedAvailableOptions.recentReports ?? []).length !== 0, !!orderedAvailableOptions?.userToInvite, cleanSearchTerm, countryCode, attendees.some((attendee) => getPersonalDetailSearchTerms(attendee, currentUserAccountID).join(' ').toLowerCase().includes(cleanSearchTerm)), ); + sections = newSections; + } - return [newSections, headerMessage]; - }, [ - areOptionsInitialized, - didScreenTransitionEnd, - searchTerm, - initialSelectedOptions, - attendees, - orderedAvailableOptions.recentReports, - orderedAvailableOptions.personalDetails, - orderedAvailableOptions.userToInvite, - personalDetails, - reportAttributesDerived, - loginList, - countryCode, - translate, - currentUserAccountID, - currentUserEmail, - ]); - - const optionLength = useMemo(() => { - if (!areOptionsInitialized) { - return 0; - } - return sections.reduce((acc, section) => acc + (section.data?.length ?? 0), 0); - }, [areOptionsInitialized, sections]); + const optionLength = !areOptionsInitialized ? 0 : sections.reduce((acc, section) => acc + (section.data?.length ?? 0), 0); - const shouldShowListEmptyContent = useMemo(() => optionLength === 0 && !showLoadingPlaceholder, [optionLength, showLoadingPlaceholder]); + const shouldShowListEmptyContent = optionLength === 0 && !showLoadingPlaceholder; const textInputOptions = { label: translate('selectionList.nameEmailOrPhoneNumber'), From cd651b173b9338af095af33713716ec4616d7260 Mon Sep 17 00:00:00 2001 From: Zuzanna Furtak Date: Mon, 9 Feb 2026 14:15:11 +0100 Subject: [PATCH 4/4] Adjust --- src/pages/iou/request/MoneyRequestAttendeeSelector.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx b/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx index fc41cf6ec80a..b2989723bb2a 100644 --- a/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx +++ b/src/pages/iou/request/MoneyRequestAttendeeSelector.tsx @@ -295,6 +295,7 @@ function MoneyRequestAttendeeSelector({attendees = [], onFinish, onAttendeesAdde listEmptyContent={} shouldPreventDefaultFocusOnSelectRow={!canUseTouchScreen()} onEndReached={onListEndReached} + disableMaintainingScrollPosition shouldSingleExecuteRowSelect shouldShowTextInput canSelectMultiple