Skip to content

Commit

Permalink
get the correct report icons when user is admin
Browse files Browse the repository at this point in the history
  • Loading branch information
marcochavezf committed Feb 23, 2022
1 parent 0dab98c commit 7195cd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,13 +787,6 @@ function getReportIcons(report, personalDetails) {
return [''];
}

const sortedParticipants = _.map(report.participants, dmParticipant => ({
firstName: lodashGet(personalDetails, [dmParticipant, 'firstName'], ''),
avatar: lodashGet(personalDetails, [dmParticipant, 'avatarThumbnail'], '')
|| getDefaultAvatar(dmParticipant),
}))
.sort((first, second) => first.firstName - second.firstName);

if (ReportUtils.isPolicyExpenseChat(report)) {
const policyExpenseChatAvatarURL = lodashGet(policies, [
`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'avatarURL',
Expand All @@ -804,10 +797,17 @@ function getReportIcons(report, personalDetails) {
return [policyExpenseChatAvatarURL];
}

// If the user is an admin, return avatar url of the other participant of the report (this is their workspace chat) and the avatar url of the workspace
return [_.first(sortedParticipants).avatar, policyExpenseChatAvatarURL];
// If the user is an admin, return avatar url of the other participant of the report
// (their workspace chat) and the avatar url of the workspace
return [lodashGet(personalDetails, [report.ownerEmail, 'avatarThumbnail']), policyExpenseChatAvatarURL];
}

const sortedParticipants = _.map(report.participants, dmParticipant => ({
firstName: lodashGet(personalDetails, [dmParticipant, 'firstName'], ''),
avatar: lodashGet(personalDetails, [dmParticipant, 'avatarThumbnail'], '')
|| getDefaultAvatar(dmParticipant),
}))
.sort((first, second) => first.firstName - second.firstName);
return _.map(sortedParticipants, item => item.avatar);
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/PersonalDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function getFromReportParticipants(reports) {
// skip over default rooms which aren't named by participants.
const reportsToUpdate = {};
_.each(reports, (report) => {
if (report.participants.length <= 0 && !ReportUtils.isChatRoom(report)) {
if (report.participants.length <= 0 && !ReportUtils.isChatRoom(report) && !ReportUtils.isPolicyExpenseChat(report)) {
return;
}

Expand Down

0 comments on commit 7195cd2

Please sign in to comment.