From 841ca52a8d5250981103f6b6972558d2643741ee Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 23 Sep 2024 23:34:20 +0300 Subject: [PATCH 1/3] remove pending delete members name from default group chat name --- src/libs/ReportUtils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index d38d3f8b950e..7bd57bd63efd 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2143,7 +2143,14 @@ function getGroupChatName(participants?: SelectedParticipant[], shouldApplyLimit return report.reportName; } - let participantAccountIDs = participants?.map((participant) => participant.accountID) ?? Object.keys(report?.participants ?? {}).map(Number); + let participantAccountIDs = + participants?.map((participant) => participant.accountID) ?? + Object.keys(report?.participants ?? {}) + .map(Number) + .filter((accountID) => { + const pendingMember = report?.pendingChatMembers?.find((member) => member.accountID === accountID.toString()); + return !(pendingMember && pendingMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); + }); if (shouldApplyLimit) { participantAccountIDs = participantAccountIDs.slice(0, 5); } From 008b5541f9891af535ff99d49f149d41c6894197 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Tue, 24 Sep 2024 15:44:41 +0300 Subject: [PATCH 2/3] refactored code --- src/libs/ReportUtils.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 7bd57bd63efd..bfd8c93be89f 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2143,14 +2143,14 @@ function getGroupChatName(participants?: SelectedParticipant[], shouldApplyLimit return report.reportName; } + const pendingMemberAccountIDs = new Set( + report?.pendingChatMembers?.filter((member) => member.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE).map((member) => member.accountID), + ); let participantAccountIDs = participants?.map((participant) => participant.accountID) ?? Object.keys(report?.participants ?? {}) .map(Number) - .filter((accountID) => { - const pendingMember = report?.pendingChatMembers?.find((member) => member.accountID === accountID.toString()); - return !(pendingMember && pendingMember.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); - }); + .filter((accountID) => !pendingMemberAccountIDs.has(accountID.toString())); if (shouldApplyLimit) { participantAccountIDs = participantAccountIDs.slice(0, 5); } From 010fcb0f516317010737c3d58dbe70ad891d90d2 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Tue, 24 Sep 2024 18:32:44 +0300 Subject: [PATCH 3/3] fixed similar problem in header view --- src/pages/home/HeaderView.tsx | 2 +- src/pages/home/ReportScreen.tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index 14ed4b583baf..51582f0b2092 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -65,7 +65,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto const isSelfDM = ReportUtils.isSelfDM(report); const isGroupChat = ReportUtils.isGroupChat(report) || ReportUtils.isDeprecatedGroupDM(report); - const participants = ReportUtils.getParticipantsAccountIDsForDisplay(report).slice(0, 5); + const participants = ReportUtils.getParticipantsAccountIDsForDisplay(report, false, true).slice(0, 5); const isMultipleParticipant = participants.length > 1; const participantPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs(participants, personalDetails); diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index b8b551a345ca..baf48775011f 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -211,6 +211,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro permissions, invoiceReceiver: reportOnyx.invoiceReceiver, policyAvatar: reportOnyx.policyAvatar, + pendingChatMembers: reportOnyx.pendingChatMembers, }, [reportOnyx, permissions], );