From 6953dbcab0d9c9614a6a9f32d5897d21087a2c08 Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Thu, 2 Jan 2025 10:17:57 +0700 Subject: [PATCH 1/5] fix: invite/remove room member action displays incorrectly in thread header --- src/libs/ReportUtils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 589c5f1a6adc..05ad808e9c22 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3832,15 +3832,17 @@ function getAdminRoomInvitedParticipants(parentReportAction: OnyxEntry { - const name = getDisplayNameForParticipant(id); + const personalDetail = personalDetails.find((personal) => personal.accountID === id); + const name = PersonalDetailsUtils.getEffectiveDisplayName(personalDetail) ?? Localize.translateLocal('common.hidden'); if (name && name?.length > 0) { return name; } From 5ea16193f107bb336dafc76b99eb7a2aa65c9cf6 Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Thu, 2 Jan 2025 15:17:21 +0700 Subject: [PATCH 2/5] refactor function and add unit test for remove room member function --- src/libs/ReportUtils.ts | 5 ++--- tests/unit/ReportUtilsTest.ts | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 05ad808e9c22..04591a5503e5 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3840,9 +3840,8 @@ function getAdminRoomInvitedParticipants(parentReportAction: OnyxEntry { - const personalDetail = personalDetails.find((personal) => personal.accountID === id); - const name = PersonalDetailsUtils.getEffectiveDisplayName(personalDetail) ?? Localize.translateLocal('common.hidden'); + const participants = personalDetails.map((personalDetail) => { + const name = PersonalDetailsUtils.getEffectiveDisplayName(personalDetail); if (name && name?.length > 0) { return name; } diff --git a/tests/unit/ReportUtilsTest.ts b/tests/unit/ReportUtilsTest.ts index bc3d5baa4bff..259a470432b7 100644 --- a/tests/unit/ReportUtilsTest.ts +++ b/tests/unit/ReportUtilsTest.ts @@ -312,6 +312,25 @@ describe('ReportUtils', () => { expect(ReportUtils.getReportName(threadOfSubmittedReportAction, policy, submittedParentReportAction)).toBe('submitted $1.69'); }); + + test('Invited/Removed Room Member Action', () => { + const threadOfRemovedRoomMemberAction = { + ...LHNTestUtils.getFakeReport(), + type: CONST.REPORT.TYPE.CHAT, + chatType: CONST.REPORT.CHAT_TYPE.POLICY_ROOM, + parentReportID: '101', + parentReportActionID: '102', + policyID: policy.id, + }; + const removedParentReportAction = { + actionName: CONST.REPORT.ACTIONS.TYPE.ROOM_CHANGE_LOG.REMOVE_FROM_ROOM, + originalMessage: { + targetAccountIDs: [1], + }, + } as ReportAction; + + expect(ReportUtils.getReportName(threadOfRemovedRoomMemberAction, policy, removedParentReportAction)).toBe('removed ragnar@vikings.net'); + }); }); }); From d386c9ae3e1282969e973c90d404ee9e45368356 Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Thu, 2 Jan 2025 22:12:46 +0700 Subject: [PATCH 3/5] remove unused variable --- src/libs/ReportUtils.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 04591a5503e5..c63b480b4ef1 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -3837,8 +3837,7 @@ function getAdminRoomInvitedParticipants(parentReportAction: OnyxEntry { const name = PersonalDetailsUtils.getEffectiveDisplayName(personalDetail); From 9b1d7c90eedb02e9864ca88b17eb51d0d3c31b96 Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Thu, 2 Jan 2025 22:22:23 +0700 Subject: [PATCH 4/5] fix test --- tests/ui/GroupChatNameTests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/GroupChatNameTests.tsx b/tests/ui/GroupChatNameTests.tsx index fc383efe4e28..d679a9f0d209 100644 --- a/tests/ui/GroupChatNameTests.tsx +++ b/tests/ui/GroupChatNameTests.tsx @@ -66,7 +66,7 @@ const USER_H_EMAIL = 'user_h@test.com'; */ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Promise { // Render the App and sign in as a test user. - render(); + render(); const participants: Record = {}; participantAccountIDs?.forEach((id) => { From 5c7415e86b83c708e0e9483a2c2de034a1cf0136 Mon Sep 17 00:00:00 2001 From: mkzie2 Date: Thu, 2 Jan 2025 22:22:33 +0700 Subject: [PATCH 5/5] fix lint error --- tests/ui/GroupChatNameTests.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/GroupChatNameTests.tsx b/tests/ui/GroupChatNameTests.tsx index d679a9f0d209..fc383efe4e28 100644 --- a/tests/ui/GroupChatNameTests.tsx +++ b/tests/ui/GroupChatNameTests.tsx @@ -66,7 +66,7 @@ const USER_H_EMAIL = 'user_h@test.com'; */ function signInAndGetApp(reportName = '', participantAccountIDs?: number[]): Promise { // Render the App and sign in as a test user. - render(); + render(); const participants: Record = {}; participantAccountIDs?.forEach((id) => {