Skip to content

Commit

Permalink
Merge pull request #43626 from Expensify/jasper-defaultRoomsEmptyPart…
Browse files Browse the repository at this point in the history
…icipantsChatFinder

Update search to work with chat rooms with empty participants + prevent searching for chat rooms by participant
  • Loading branch information
jasperhuangg authored Jul 8, 2024
2 parents 2354386 + 31d0194 commit 6acc21c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
11 changes: 5 additions & 6 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2490,11 +2490,6 @@ function filterOptions(options: Options, searchInputValue: string, config?: Filt
values.push(item.login.replace(emailRegex, ''));
}

if (!item.isChatRoom) {
const participantNames = getParticipantNames(item.participantsList ?? []);
values = values.concat(Array.from(participantNames));
}

if (item.isThread) {
if (item.alternateText) {
values.push(item.alternateText);
Expand All @@ -2504,7 +2499,11 @@ function filterOptions(options: Options, searchInputValue: string, config?: Filt
if (item.subtitle) {
values.push(item.subtitle);
}
} else {
}

if (!item.isChatRoom) {
const participantNames = getParticipantNames(item.participantsList ?? []);
values = values.concat(Array.from(participantNames));
values = values.concat(getParticipantsLoginsArray(item));
}

Expand Down
10 changes: 5 additions & 5 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ function isOpenInvoiceReport(report: OnyxEntry<Report>): boolean {
* Whether the provided report is a chat room
*/
function isChatRoom(report: OnyxEntry<Report>): boolean {
return isUserCreatedPolicyRoom(report) || isDefaultRoom(report) || isInvoiceRoom(report);
return isUserCreatedPolicyRoom(report) || isDefaultRoom(report) || isInvoiceRoom(report) || isTripRoom(report);
}

/**
Expand Down Expand Up @@ -5417,16 +5417,16 @@ function shouldReportBeInOptionList({
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
report?.isHidden ||
(!report?.participants &&
// We omit sending back participants for chat rooms when searching for reports since they aren't needed to display the results and can get very large.
// So we allow showing rooms with no participants–in any other circumstances we should never have these reports with no participants in Onyx.
!isChatRoom(report) &&
!isChatThread(report) &&
!isPublicRoom(report) &&
!isUserCreatedPolicyRoom(report) &&
!isArchivedRoom(report) &&
!isMoneyRequestReport(report) &&
!isTaskReport(report) &&
!isSelfDM(report) &&
!isSystemChat(report) &&
!isGroupChat(report) &&
!isInvoiceRoom(report))
!isGroupChat(report))
) {
return false;
}
Expand Down

0 comments on commit 6acc21c

Please sign in to comment.