From cb446afcb0306f57fbf55114506320891cd8aff8 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Sun, 7 Apr 2024 01:55:32 +0530 Subject: [PATCH 01/12] Fix incorrect length of participants in report details --- src/pages/ReportDetailsPage.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 9093bf32b9dd..508b7f1d452b 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -80,6 +80,9 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const chatRoomSubtitle = useMemo(() => ReportUtils.getChatRoomSubtitle(report), [report, policy]); const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(report); const participants = useMemo(() => ReportUtils.getVisibleMemberIDs(report), [report]); + const NonpendingChatMembers = report?.participantAccountIDs + ?.map((accountID) => report.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString())) + .filter((member) => !member || member.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); const isGroupDMChat = useMemo(() => ReportUtils.isDM(report) && participants.length > 1, [report, participants.length]); @@ -131,7 +134,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD key: CONST.REPORT_DETAILS_MENU_ITEM.MEMBERS, translationKey: 'common.members', icon: Expensicons.Users, - subtitle: participants.length, + subtitle: NonpendingChatMembers.length, isAnonymousAction: false, action: () => { if (isUserCreatedPolicyRoom || isChatThread) { From 535f35180b2565bd1a99061d1c27003429dfb411 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Sun, 7 Apr 2024 02:01:47 +0530 Subject: [PATCH 02/12] fix null check --- src/pages/ReportDetailsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 508b7f1d452b..de7994a5a0e6 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -134,7 +134,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD key: CONST.REPORT_DETAILS_MENU_ITEM.MEMBERS, translationKey: 'common.members', icon: Expensicons.Users, - subtitle: NonpendingChatMembers.length, + subtitle: NonpendingChatMembers?.length, isAnonymousAction: false, action: () => { if (isUserCreatedPolicyRoom || isChatThread) { From 06c87118a48d5d41a4395a75b0093bc385a0860f Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Thu, 11 Apr 2024 05:25:57 +0530 Subject: [PATCH 03/12] use flatmap and change vairable name --- src/pages/ReportDetailsPage.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 973470d7f957..4fedcd41fc56 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -80,8 +80,8 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const chatRoomSubtitle = useMemo(() => ReportUtils.getChatRoomSubtitle(report), [report, policy]); const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(report); const participants = useMemo(() => ReportUtils.getVisibleMemberIDs(report), [report]); - const NonpendingChatMembers = report?.participantAccountIDs - ?.map((accountID) => report.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString())) + const activeChatMembers = report?.participantAccountIDs + ?.flatMap((accountID) => report.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString())) .filter((member) => !member || member.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); const isGroupDMChat = useMemo(() => ReportUtils.isDM(report) && participants.length > 1, [report, participants.length]); @@ -134,7 +134,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD key: CONST.REPORT_DETAILS_MENU_ITEM.MEMBERS, translationKey: 'common.members', icon: Expensicons.Users, - subtitle: NonpendingChatMembers?.length, + subtitle: activeChatMembers?.length, isAnonymousAction: false, action: () => { if (isUserCreatedPolicyRoom || isChatThread) { @@ -256,7 +256,6 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD )} From 350b603d0e0562c25206dfac4fe9f9ee9346aa27 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Thu, 11 Apr 2024 05:52:06 +0530 Subject: [PATCH 04/12] fix lint --- src/pages/ReportDetailsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 4fedcd41fc56..55861fc5b597 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -182,7 +182,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD } return items; - }, [isArchivedRoom, participants.length, isChatThread, isMoneyRequestReport, report, isGroupDMChat, isPolicyMember, isUserCreatedPolicyRoom, session, isSelfDM, isDefaultRoom]); + }, [isArchivedRoom, participants.length, isChatThread, isMoneyRequestReport, report, isGroupDMChat, isPolicyMember, isUserCreatedPolicyRoom, session, isSelfDM, isDefaultRoom, activeChatMembers?.length]); const displayNamesWithTooltips = useMemo(() => { const hasMultipleParticipants = participants.length > 1; From 0b495ff9e68975dbb1a3c86088d9f614cdd27c61 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Thu, 11 Apr 2024 05:59:48 +0530 Subject: [PATCH 05/12] fix lint --- src/pages/ReportDetailsPage.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 55861fc5b597..90a01efb48ee 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -182,7 +182,20 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD } return items; - }, [isArchivedRoom, participants.length, isChatThread, isMoneyRequestReport, report, isGroupDMChat, isPolicyMember, isUserCreatedPolicyRoom, session, isSelfDM, isDefaultRoom, activeChatMembers?.length]); + }, [ + isArchivedRoom, + participants.length, + isChatThread, + isMoneyRequestReport, + report, + isGroupDMChat, + isPolicyMember, + isUserCreatedPolicyRoom, + session, + isSelfDM, + isDefaultRoom, + activeChatMembers?.length, + ]); const displayNamesWithTooltips = useMemo(() => { const hasMultipleParticipants = participants.length > 1; From 3112b7644923172b7d95bc0d43699f64727ff640 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Thu, 11 Apr 2024 18:05:55 +0530 Subject: [PATCH 06/12] Use particpants instead --- src/pages/ReportDetailsPage.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 90a01efb48ee..cbd3cebd8175 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -80,9 +80,10 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const chatRoomSubtitle = useMemo(() => ReportUtils.getChatRoomSubtitle(report), [report, policy]); const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(report); const participants = useMemo(() => ReportUtils.getVisibleMemberIDs(report), [report]); - const activeChatMembers = report?.participantAccountIDs - ?.flatMap((accountID) => report.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString())) - .filter((member) => !member || member.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); + const activeChatMembers = participants.flatMap((accountID) => { + const pendingMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString()); + return !pendingMember || pendingMember.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? accountID : []; + }); const isGroupDMChat = useMemo(() => ReportUtils.isDM(report) && participants.length > 1, [report, participants.length]); From 79d3ba66031eb0d6ddbfc82e3294ce99a3394f16 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Thu, 11 Apr 2024 18:07:04 +0530 Subject: [PATCH 07/12] Fix unintended delete --- src/pages/ReportDetailsPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index cbd3cebd8175..8ce50d3537c3 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -270,6 +270,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD )} From 7bdeca4ac6ed1c7fe595f8e294ff654772d2206d Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Thu, 11 Apr 2024 23:19:44 +0530 Subject: [PATCH 08/12] Revert back to participantsAccountIDs --- src/pages/ReportDetailsPage.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 8ce50d3537c3..f2c3c117d765 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -80,10 +80,9 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const chatRoomSubtitle = useMemo(() => ReportUtils.getChatRoomSubtitle(report), [report, policy]); const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(report); const participants = useMemo(() => ReportUtils.getVisibleMemberIDs(report), [report]); - const activeChatMembers = participants.flatMap((accountID) => { - const pendingMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString()); - return !pendingMember || pendingMember.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? accountID : []; - }); + const activeChatMembers = report?.participantAccountIDs + ?.flatMap((accountID) => report.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString())) + .filter((member) => !member || member.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); const isGroupDMChat = useMemo(() => ReportUtils.isDM(report) && participants.length > 1, [report, participants.length]); From 6e1d4b20532b4f7f1c826e98fb3ff5e0dec4d990 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Fri, 12 Apr 2024 17:40:34 +0530 Subject: [PATCH 09/12] Implement latest suggestions --- src/pages/ReportDetailsPage.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index f2c3c117d765..8ce50d3537c3 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -80,9 +80,10 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD const chatRoomSubtitle = useMemo(() => ReportUtils.getChatRoomSubtitle(report), [report, policy]); const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(report); const participants = useMemo(() => ReportUtils.getVisibleMemberIDs(report), [report]); - const activeChatMembers = report?.participantAccountIDs - ?.flatMap((accountID) => report.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString())) - .filter((member) => !member || member.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE); + const activeChatMembers = participants.flatMap((accountID) => { + const pendingMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString()); + return !pendingMember || pendingMember.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? accountID : []; + }); const isGroupDMChat = useMemo(() => ReportUtils.isDM(report) && participants.length > 1, [report, participants.length]); From 76bc4007af04f1cec456581893d300a31800406c Mon Sep 17 00:00:00 2001 From: Gandalf Date: Sat, 13 Apr 2024 01:15:57 +0530 Subject: [PATCH 10/12] Update src/pages/ReportDetailsPage.tsx Co-authored-by: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> --- src/pages/ReportDetailsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 8ce50d3537c3..ab723c8dd472 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -135,7 +135,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD key: CONST.REPORT_DETAILS_MENU_ITEM.MEMBERS, translationKey: 'common.members', icon: Expensicons.Users, - subtitle: activeChatMembers?.length, + subtitle: activeChatMembers.length, isAnonymousAction: false, action: () => { if (isUserCreatedPolicyRoom || isChatThread) { From c1065517b8512052a5fdf57fd248cf42a493cb22 Mon Sep 17 00:00:00 2001 From: Gandalf Date: Sat, 13 Apr 2024 01:16:40 +0530 Subject: [PATCH 11/12] Update src/pages/ReportDetailsPage.tsx Co-authored-by: rayane-djouah <77965000+rayane-djouah@users.noreply.github.com> --- src/pages/ReportDetailsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index ab723c8dd472..ecceb5ec7d3c 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -195,7 +195,7 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD session, isSelfDM, isDefaultRoom, - activeChatMembers?.length, + activeChatMembers.length, ]); const displayNamesWithTooltips = useMemo(() => { From f742baacd671a292e6aabbb2b26d9170659e2141 Mon Sep 17 00:00:00 2001 From: GandalfGwaihir Date: Mon, 15 Apr 2024 21:00:01 +0530 Subject: [PATCH 12/12] Resolve merge conflict --- src/pages/ReportDetailsPage.tsx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/pages/ReportDetailsPage.tsx b/src/pages/ReportDetailsPage.tsx index 0d6f19cd88b8..7f1dadab8c0e 100644 --- a/src/pages/ReportDetailsPage.tsx +++ b/src/pages/ReportDetailsPage.tsx @@ -81,13 +81,6 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD // eslint-disable-next-line react-hooks/exhaustive-deps -- policy is a dependency because `getChatRoomSubtitle` calls `getPolicyName` which in turn retrieves the value from the `policy` value stored in Onyx const chatRoomSubtitle = useMemo(() => ReportUtils.getChatRoomSubtitle(report), [report, policy]); const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(report); -<<<<<<< HEAD - const participants = useMemo(() => ReportUtils.getVisibleMemberIDs(report), [report]); - const activeChatMembers = participants.flatMap((accountID) => { - const pendingMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString()); - return !pendingMember || pendingMember.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? accountID : []; - }); -======= const isGroupChat = useMemo(() => ReportUtils.isGroupChat(report), [report]); const participants = useMemo(() => { if (isGroupChat) { @@ -96,7 +89,12 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD return ReportUtils.getVisibleChatMemberAccountIDs(report.reportID ?? ''); }, [report, isGroupChat]); ->>>>>>> main + + // Get the active chat members by filtering out the pending members with delete action + const activeChatMembers = participants.flatMap((accountID) => { + const pendingMember = report?.pendingChatMembers?.findLast((member) => member.accountID === accountID.toString()); + return !pendingMember || pendingMember.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE ? accountID : []; + }); const isGroupDMChat = useMemo(() => ReportUtils.isDM(report) && participants.length > 1, [report, participants.length]); const isPrivateNotesFetchTriggered = report?.isLoadingPrivateNotes !== undefined; @@ -208,11 +206,8 @@ function ReportDetailsPage({policies, report, session, personalDetails}: ReportD session, isSelfDM, isDefaultRoom, -<<<<<<< HEAD activeChatMembers.length, -======= isGroupChat, ->>>>>>> main ]); const displayNamesWithTooltips = useMemo(() => {