Skip to content

Commit 20f13e8

Browse files
yuwenmemonOSBotify
authored andcommitted
Merge pull request #44505 from Expensify/yuwen-fixSplitSelection
[CP Staging] Fix selection for splits when there is a search term present (cherry picked from commit 47fafdb)
1 parent 98e5373 commit 20f13e8

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/pages/iou/request/MoneyRequestParticipantsSelector.tsx

+17-5
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ type MoneyRequestParticipantsSelectorProps = {
3434

3535
/** Callback to add participants in MoneyRequestModal */
3636
onParticipantsAdded: (value: Participant[]) => void;
37+
3738
/** Selected participants from MoneyRequestModal with login */
38-
participants?: Participant[];
39+
participants?: Participant[] | typeof CONST.EMPTY_ARRAY;
3940

4041
/** The type of IOU report, i.e. split, request, send, track */
4142
iouType: IOUType;
@@ -47,7 +48,7 @@ type MoneyRequestParticipantsSelectorProps = {
4748
action: IOUAction;
4849
};
4950

50-
function MoneyRequestParticipantsSelector({participants = [], onFinish, onParticipantsAdded, iouType, iouRequestType, action}: MoneyRequestParticipantsSelectorProps) {
51+
function MoneyRequestParticipantsSelector({participants = CONST.EMPTY_ARRAY, onFinish, onParticipantsAdded, iouType, iouRequestType, action}: MoneyRequestParticipantsSelectorProps) {
5152
const {translate} = useLocalize();
5253
const styles = useThemeStyles();
5354
const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState('');
@@ -94,7 +95,7 @@ function MoneyRequestParticipantsSelector({participants = [], onFinish, onPartic
9495
options.personalDetails,
9596
betas,
9697
'',
97-
participants,
98+
participants as Participant[],
9899
CONST.EXPENSIFY_EMAILS,
99100

100101
// 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
153154

154155
const newOptions = OptionsListUtils.filterOptions(defaultOptions, debouncedSearchTerm, {
155156
betas,
156-
selectedOptions: participants,
157+
selectedOptions: participants as Participant[],
157158
excludeLogins: CONST.EXPENSIFY_EMAILS,
158159
maxRecentReportsToShow: CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW,
159160
});
@@ -378,6 +379,17 @@ function MoneyRequestParticipantsSelector({participants = [], onFinish, onPartic
378379
onFinish,
379380
]);
380381

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+
381393
return (
382394
<SelectionList
383395
onConfirm={handleConfirmSelection}
@@ -388,7 +400,7 @@ function MoneyRequestParticipantsSelector({participants = [], onFinish, onPartic
388400
textInputHint={offlineMessage}
389401
onChangeText={setSearchTerm}
390402
shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()}
391-
onSelectRow={(item) => (isIOUSplit ? addParticipantToSelection(item) : addSingleParticipant(item))}
403+
onSelectRow={onSelectRow}
392404
shouldDebounceRowSelect
393405
footerContent={footerContent}
394406
headerMessage={header}

0 commit comments

Comments
 (0)