11import React , { useMemo } from 'react' ;
2- import type { SectionListData } from 'react-native' ;
32import useDebouncedState from '@hooks/useDebouncedState' ;
43import useLocalize from '@hooks/useLocalize' ;
54import useOnyx from '@hooks/useOnyx' ;
@@ -15,9 +14,8 @@ import ONYXKEYS from '@src/ONYXKEYS';
1514import type { Icon } from '@src/types/onyx/OnyxCommon' ;
1615import { FallbackAvatar } from './Icon/Expensicons' ;
1716import { usePersonalDetails } from './OnyxListItemProvider' ;
18- import SelectionList from './SelectionListWithSections' ;
19- import InviteMemberListItem from './SelectionListWithSections/InviteMemberListItem' ;
20- import type { Section } from './SelectionListWithSections/types' ;
17+ import SelectionList from './SelectionList' ;
18+ import InviteMemberListItem from './SelectionList/ListItem/InviteMemberListItem' ;
2119
2220type SelectionListApprover = {
2321 text : string ;
@@ -29,7 +27,6 @@ type SelectionListApprover = {
2927 icons : Icon [ ] ;
3028 value ?: number ;
3129} ;
32- type ApproverSection = SectionListData < SelectionListApprover , Section < SelectionListApprover > > ;
3330
3431type WorkspaceMembersSelectionListProps = {
3532 policyID : string ;
@@ -45,7 +42,7 @@ function WorkspaceMembersSelectionList({policyID, selectedApprover, setApprover}
4542 const policy = usePolicy ( policyID ) ;
4643 const [ countryCode = CONST . DEFAULT_COUNTRY_CODE ] = useOnyx ( ONYXKEYS . COUNTRY_CODE , { canBeMissing : false } ) ;
4744
48- const sections : ApproverSection [ ] = useMemo ( ( ) => {
45+ const orderedApprovers = useMemo ( ( ) => {
4946 const approvers : SelectionListApprover [ ] = [ ] ;
5047
5148 if ( policy ?. employeeList ) {
@@ -84,34 +81,34 @@ function WorkspaceMembersSelectionList({policyID, selectedApprover, setApprover}
8481
8582 const filteredApprovers = tokenizedSearch ( approvers , getSearchValueForPhoneOrEmail ( debouncedSearchTerm , countryCode ) , ( approver ) => [ approver . text ?? '' , approver . login ?? '' ] ) ;
8683
87- return [
88- {
89- title : undefined ,
90- data : sortAlphabetically ( filteredApprovers , 'text' , localeCompare ) ,
91- shouldShow : true ,
92- } ,
93- ] ;
84+ return sortAlphabetically ( filteredApprovers , 'text' , localeCompare ) ;
9485 } , [ policy ?. employeeList , policy ?. owner , debouncedSearchTerm , countryCode , localeCompare , personalDetails , selectedApprover ] ) ;
9586
9687 const handleOnSelectRow = ( approver : SelectionListApprover ) => {
9788 setApprover ( approver . login ) ;
9889 } ;
9990
100- const headerMessage = useMemo ( ( ) => ( searchTerm && ! sections . at ( 0 ) ?. data . length ? translate ( 'common.noResultsFound' ) : '' ) , [ searchTerm , sections , translate ] ) ;
91+ const textInputOptions = useMemo (
92+ ( ) => ( {
93+ label : translate ( 'selectionList.nameEmailOrPhoneNumber' ) ,
94+ value : searchTerm ,
95+ headerMessage : searchTerm && ! orderedApprovers . length ? translate ( 'common.noResultsFound' ) : '' ,
96+ onChangeText : setSearchTerm ,
97+ } ) ,
98+ [ searchTerm , orderedApprovers , setSearchTerm , translate ] ,
99+ ) ;
101100
102101 return (
103102 < SelectionList
104- sections = { sections }
103+ data = { orderedApprovers }
105104 ListItem = { InviteMemberListItem }
106- textInputLabel = { translate ( 'selectionList.nameEmailOrPhoneNumber' ) }
107- textInputValue = { searchTerm }
108- onChangeText = { setSearchTerm }
109- headerMessage = { headerMessage }
110105 onSelectRow = { handleOnSelectRow }
111- showScrollIndicator
106+ textInputOptions = { textInputOptions }
112107 showLoadingPlaceholder = { ! didScreenTransitionEnd }
113108 shouldPreventDefaultFocusOnSelectRow = { ! canUseTouchScreen ( ) }
109+ disableMaintainingScrollPosition
114110 addBottomSafeAreaPadding
111+ showScrollIndicator
115112 />
116113 ) ;
117114}
0 commit comments