@@ -79,6 +79,9 @@ type UseSearchSelectorConfig = {
7979
8080 /** Whether to allow name-only options */
8181 shouldAllowNameOnlyOptions ?: boolean ;
82+
83+ /** Whether to keep selected options in availableOptions instead of filtering them out */
84+ shouldKeepSelectedInAvailableOptions ?: boolean ;
8285} ;
8386
8487type ContactState = {
@@ -170,6 +173,7 @@ function useSearchSelectorBase({
170173 includeSelfDM = false ,
171174 recentAttendees,
172175 shouldAllowNameOnlyOptions = false ,
176+ shouldKeepSelectedInAvailableOptions = false ,
173177} : UseSearchSelectorConfig ) : UseSearchSelectorReturn {
174178 const { options : defaultOptions , areOptionsInitialized} = useOptionsList ( {
175179 shouldInitialize,
@@ -352,18 +356,17 @@ function useSearchSelectorBase({
352356 : null ,
353357 } ;
354358
355- const isSingleSelect = selectionMode === CONST . SEARCH_SELECTOR . SELECTION_MODE_SINGLE ;
356- const filteredRecentReports = isSingleSelect ? searchOptions . recentReports : searchOptions . recentReports . filter ( ( option ) => ! option . isSelected ) ;
359+ const filteredRecentReports = shouldKeepSelectedInAvailableOptions ? searchOptions . recentReports : searchOptions . recentReports . filter ( ( option ) => ! option . isSelected ) ;
357360
358361 // Filter out people who appear in recent reports from personal details (recents take priority)
359362 const recentReportLogins = new Set ( filteredRecentReports . map ( ( option ) => option . login ) . filter ( Boolean ) ) ;
360- const filteredPersonalDetails = searchOptions . personalDetails . filter ( ( option ) => ( isSingleSelect || ! option . isSelected ) && ! recentReportLogins . has ( option . login ) ) ;
363+ const filteredPersonalDetails = searchOptions . personalDetails . filter ( ( option ) => ( shouldKeepSelectedInAvailableOptions || ! option . isSelected ) && ! recentReportLogins . has ( option . login ) ) ;
361364
362365 const availableOptions = {
363366 ...searchOptions ,
364367 personalDetails : filteredPersonalDetails ,
365368 recentReports : filteredRecentReports ,
366- userToInvite : ! isSingleSelect && searchOptions . userToInvite ?. isSelected ? null : searchOptions . userToInvite ,
369+ userToInvite : ! shouldKeepSelectedInAvailableOptions && searchOptions . userToInvite ?. isSelected ? null : searchOptions . userToInvite ,
367370 } ;
368371
369372 /**
0 commit comments