Skip to content

Commit

Permalink
Merge pull request #27828 from koko57/refactor/25714-replace-other-pa…
Browse files Browse the repository at this point in the history
…rticipants-usages

fix: remove deprecated getChatByParticipantsByLoginList method
  • Loading branch information
puneetlath authored Sep 25, 2023
2 parents 115029c + c5f782b commit 194a6fc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 28 deletions.
23 changes: 0 additions & 23 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2988,28 +2988,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
Expand Down Expand Up @@ -3687,7 +3665,6 @@ export {
getOptimisticDataForParentReportAction,
shouldReportBeInOptionList,
getChatByParticipants,
getChatByParticipantsByLoginList,
getChatByParticipantsAndPolicy,
getAllPolicyReports,
getIOUReportActionMessage,
Expand Down
8 changes: 4 additions & 4 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -609,10 +608,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;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,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;
Expand Down

0 comments on commit 194a6fc

Please sign in to comment.