@@ -34,8 +34,9 @@ type MoneyRequestParticipantsSelectorProps = {
34
34
35
35
/** Callback to add participants in MoneyRequestModal */
36
36
onParticipantsAdded : ( value : Participant [ ] ) => void ;
37
+
37
38
/** Selected participants from MoneyRequestModal with login */
38
- participants ?: Participant [ ] ;
39
+ participants ?: Participant [ ] | typeof CONST . EMPTY_ARRAY ;
39
40
40
41
/** The type of IOU report, i.e. split, request, send, track */
41
42
iouType : IOUType ;
@@ -47,7 +48,7 @@ type MoneyRequestParticipantsSelectorProps = {
47
48
action : IOUAction ;
48
49
} ;
49
50
50
- function MoneyRequestParticipantsSelector ( { participants = [ ] , onFinish, onParticipantsAdded, iouType, iouRequestType, action} : MoneyRequestParticipantsSelectorProps ) {
51
+ function MoneyRequestParticipantsSelector ( { participants = CONST . EMPTY_ARRAY , onFinish, onParticipantsAdded, iouType, iouRequestType, action} : MoneyRequestParticipantsSelectorProps ) {
51
52
const { translate} = useLocalize ( ) ;
52
53
const styles = useThemeStyles ( ) ;
53
54
const [ searchTerm , debouncedSearchTerm , setSearchTerm ] = useDebouncedState ( '' ) ;
@@ -94,7 +95,7 @@ function MoneyRequestParticipantsSelector({participants = [], onFinish, onPartic
94
95
options . personalDetails ,
95
96
betas ,
96
97
'' ,
97
- participants ,
98
+ participants as Participant [ ] ,
98
99
CONST . EXPENSIFY_EMAILS ,
99
100
100
101
// If we are using this component in the "Submit expense" flow then we pass the includeOwnedWorkspaceChats argument so that the current user
@@ -153,7 +154,7 @@ function MoneyRequestParticipantsSelector({participants = [], onFinish, onPartic
153
154
154
155
const newOptions = OptionsListUtils . filterOptions ( defaultOptions , debouncedSearchTerm , {
155
156
betas,
156
- selectedOptions : participants ,
157
+ selectedOptions : participants as Participant [ ] ,
157
158
excludeLogins : CONST . EXPENSIFY_EMAILS ,
158
159
maxRecentReportsToShow : CONST . IOU . MAX_RECENT_REPORTS_TO_SHOW ,
159
160
} ) ;
@@ -378,6 +379,17 @@ function MoneyRequestParticipantsSelector({participants = [], onFinish, onPartic
378
379
onFinish ,
379
380
] ) ;
380
381
382
+ const onSelectRow = useCallback (
383
+ ( item : Participant ) => {
384
+ if ( isIOUSplit ) {
385
+ addParticipantToSelection ( item ) ;
386
+ return ;
387
+ }
388
+ addSingleParticipant ( item ) ;
389
+ } ,
390
+ [ isIOUSplit , addParticipantToSelection , addSingleParticipant ] ,
391
+ ) ;
392
+
381
393
return (
382
394
< SelectionList
383
395
onConfirm = { handleConfirmSelection }
@@ -388,7 +400,7 @@ function MoneyRequestParticipantsSelector({participants = [], onFinish, onPartic
388
400
textInputHint = { offlineMessage }
389
401
onChangeText = { setSearchTerm }
390
402
shouldPreventDefaultFocusOnSelectRow = { ! DeviceCapabilities . canUseTouchScreen ( ) }
391
- onSelectRow = { ( item ) => ( isIOUSplit ? addParticipantToSelection ( item ) : addSingleParticipant ( item ) ) }
403
+ onSelectRow = { onSelectRow }
392
404
shouldDebounceRowSelect
393
405
footerContent = { footerContent }
394
406
headerMessage = { header }
0 commit comments