diff --git a/src/CONST.ts b/src/CONST.ts index 672868214883..90a07b1a7a8a 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1381,7 +1381,6 @@ const CONST = { ADMIN: 'admin', AUDITOR: 'auditor', USER: 'user', - MEMBER: 'member', }, AUTO_REPORTING_FREQUENCIES: { INSTANT: 'instant', diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index b96048dc182d..6f89e58d3efe 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4278,7 +4278,8 @@ function getChatByParticipants(newParticipantList: number[], reports: OnyxCollec isTaskReport(report) || isMoneyRequestReport(report) || isChatRoom(report) || - isPolicyExpenseChat(report) + isPolicyExpenseChat(report) || + isGroupChat(report) ) { return false; } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index e0fc0081ef42..9c77ee70b1cb 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -1653,13 +1653,11 @@ function createSplitsAndOnyxData( const currentUserEmailForIOUSplit = PhoneNumber.addSMSDomainIfPhoneNumber(currentUserLogin); const participantAccountIDs = participants.map((participant) => Number(participant.accountID)); - const existingSplitChatReport = - // eslint-disable-next-line no-nested-ternary - existingSplitChatReportID || participants[0].reportID - ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${existingSplitChatReportID || participants[0].reportID}`] - : participants.length < 2 - ? ReportUtils.getChatByParticipants(participantAccountIDs) - : null; + const existingChatReportID = existingSplitChatReportID || participants[0].reportID; + let existingSplitChatReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${existingChatReportID}`]; + if (!existingSplitChatReport) { + existingSplitChatReport = participants.length < 2 ? ReportUtils.getChatByParticipants(participantAccountIDs) : null; + } const splitChatReport = existingSplitChatReport ?? ReportUtils.buildOptimisticChatReport(participantAccountIDs); const isOwnPolicyExpenseChat = !!splitChatReport.isOwnPolicyExpenseChat;