Skip to content

Commit

Permalink
Merge pull request #49618 from FitseTLT/fix-group-name-bug-on-member-…
Browse files Browse the repository at this point in the history
…removal

Fix - Group chat - After removing user, group name is not updated
  • Loading branch information
bondydaa committed Sep 25, 2024
2 parents a373b27 + 010fcb0 commit 5927028
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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) => !pendingMemberAccountIDs.has(accountID.toString()));
if (shouldApplyLimit) {
participantAccountIDs = participantAccountIDs.slice(0, 5);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/HeaderView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,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);
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro
permissions,
invoiceReceiver: reportOnyx.invoiceReceiver,
policyAvatar: reportOnyx.policyAvatar,
pendingChatMembers: reportOnyx.pendingChatMembers,
},
[reportOnyx, permissions],
);
Expand Down

0 comments on commit 5927028

Please sign in to comment.