Skip to content

Commit

Permalink
Merge pull request Expensify#54734 from mkzie2/mkzie2-issue/54621
Browse files Browse the repository at this point in the history
Fix: invite/remove room member action displays incorrectly in thread header
  • Loading branch information
marcochavezf authored Jan 2, 2025
2 parents 4dd5e08 + 5c7415e commit 1cfcfa4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3853,15 +3853,15 @@ function getAdminRoomInvitedParticipants(parentReportAction: OnyxEntry<ReportAct
if (!ReportActionsUtils.getOriginalMessage(parentReportAction)) {
return parentReportActionMessage || Localize.translateLocal('parentReportAction.deletedMessage');
}
if (!ReportActionsUtils.isPolicyChangeLogAction(parentReportAction) || !ReportActionsUtils.isRoomChangeLogAction(parentReportAction)) {
if (!ReportActionsUtils.isPolicyChangeLogAction(parentReportAction) && !ReportActionsUtils.isRoomChangeLogAction(parentReportAction)) {
return parentReportActionMessage || Localize.translateLocal('parentReportAction.deletedMessage');
}

const originalMessage = isChangeLogObject(ReportActionsUtils.getOriginalMessage(parentReportAction));
const participantAccountIDs = originalMessage?.targetAccountIDs ?? [];
const personalDetails = PersonalDetailsUtils.getPersonalDetailsByIDs(originalMessage?.targetAccountIDs ?? [], 0);

const participants = participantAccountIDs.map((id: number) => {
const name = getDisplayNameForParticipant(id);
const participants = personalDetails.map((personalDetail) => {
const name = PersonalDetailsUtils.getEffectiveDisplayName(personalDetail);
if (name && name?.length > 0) {
return name;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected]');
});
});
});

Expand Down

0 comments on commit 1cfcfa4

Please sign in to comment.