From b283e7891741232b2c6bb7bcc670954d9dff85a6 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 20 Sep 2023 08:22:55 +0200 Subject: [PATCH 1/2] fix: remove deprecated getChatByParticipantsByLoginList method --- src/libs/ReportUtils.js | 23 ----------------------- src/libs/actions/Report.js | 7 ++++--- src/libs/actions/Task.js | 2 +- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 8e9cea908f74..6d1e2eda77d3 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2928,28 +2928,6 @@ function getChatByParticipants(newParticipantList) { }); } -/** - * Attempts to find a report in onyx with the provided email list of participants. Does not include threads - * This is temporary function while migrating from PersonalDetails to PersonalDetailsList - * - * @deprecated - use getChatByParticipants() - * - * @param {Array} participantsLoginList - * @returns {Array|undefined} - */ -function getChatByParticipantsByLoginList(participantsLoginList) { - participantsLoginList.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) || isThread(report)) { - return false; - } - - // Only return the room if it has all the participants and is not a policy room - return !isUserCreatedPolicyRoom(report) && _.isEqual(participantsLoginList, _.sortBy(report.participants)); - }); -} - /** * Attempts to find a report in onyx with the provided list of participants in given policy * @param {Array} newParticipantList @@ -3605,7 +3583,6 @@ export { getOptimisticDataForParentReportAction, shouldReportBeInOptionList, getChatByParticipants, - getChatByParticipantsByLoginList, getChatByParticipantsAndPolicy, getAllPolicyReports, getIOUReportActionMessage, diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 2a34c839a94e..bbc3e6ff854f 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -559,10 +559,11 @@ function openReport(reportID, participantLoginList = [], newReportObject = {}, p */ function navigateToAndOpenReport(userLogins, shouldDismissModal = true) { let newChat = {}; - const formattedUserLogins = _.map(userLogins, (login) => OptionsListUtils.addSMSDomainIfPhoneNumber(login).toLowerCase()); - const chat = ReportUtils.getChatByParticipantsByLoginList(formattedUserLogins); + + const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins(userLogins); + const chat = ReportUtils.getChatByParticipants(participantAccountIDs); + if (!chat) { - const participantAccountIDs = PersonalDetailsUtils.getAccountIDsByLogins(userLogins); newChat = ReportUtils.buildOptimisticChatReport(participantAccountIDs); } const reportID = chat ? chat.reportID : newChat.reportID; diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index f1fb4d96f523..bc43c18dadb0 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -641,7 +641,7 @@ function setAssigneeValue(assigneeEmail, assigneeAccountID, shareDestination, is let chatReport; if (!isCurrentUser) { - chatReport = ReportUtils.getChatByParticipantsByLoginList([assigneeEmail]) || ReportUtils.getChatByParticipants([assigneeAccountID]); + chatReport = ReportUtils.getChatByParticipants([assigneeAccountID]); if (!chatReport) { chatReport = ReportUtils.buildOptimisticChatReport([assigneeAccountID]); chatReport.isOptimisticReport = true; From 6f1320b6cd8fa888bba1a03793f74c3d36e80c67 Mon Sep 17 00:00:00 2001 From: Agata Kosior Date: Wed, 20 Sep 2023 09:27:22 +0200 Subject: [PATCH 2/2] fix: fix lint error --- src/libs/actions/Report.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index bbc3e6ff854f..4d0147fe7663 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -25,7 +25,6 @@ import * as ErrorUtils from '../ErrorUtils'; import * as UserUtils from '../UserUtils'; import * as Welcome from './Welcome'; import * as PersonalDetailsUtils from '../PersonalDetailsUtils'; -import * as OptionsListUtils from '../OptionsListUtils'; import * as Environment from '../Environment/Environment'; import * as Session from './Session';