Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2183,20 +2183,28 @@ function shouldReportBeInOptionList(report, currentReportId, isInGSDMode, iouRep
}

/**
* Attempts to find a report in onyx with the provided list of participants. Does not include threads
* Attempts to find a report in onyx with the provided list of participants. Does not include threads, task, money request, room, and policy expense chat.
* @param {Array<Number>} newParticipantList
* @returns {Array|undefined}
*/
function getChatByParticipants(newParticipantList) {
newParticipantList.sort();
return _.find(allReports, (report) => {
// If the report has been deleted, or there are no participants (like an empty #admins room) then skip it
if (!report || _.isEmpty(report.participantAccountIDs) || isChatThread(report)) {
if (
!report ||
_.isEmpty(report.participantAccountIDs) ||
isChatThread(report) ||
isTaskReport(report) ||
isMoneyRequestReport(report) ||
isChatRoom(report) ||
isPolicyExpenseChat(report)
) {
return false;
}

// Only return the room if it has all the participants and is not a policy room
return !isUserCreatedPolicyRoom(report) && _.isEqual(newParticipantList, _.sortBy(report.participantAccountIDs));
// Only return the chat if it has all the participants
return _.isEqual(newParticipantList, _.sortBy(report.participantAccountIDs));
});

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isUserCreatedPolicyRoom is included in isChatRoom

}

Expand Down