Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: IOU report on LHN displays the wrong avatar #19392

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,9 +836,10 @@ function getIconsForParticipants(participants, personalDetails) {
* @param {Object} report
* @param {Object} personalDetails
* @param {*} [defaultIcon]
* @param {Boolean} [isPayer]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isPayer doesn't sound good so we will need to change it but I can't think of any good param name for this. @thienlnam, can you suggest something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahah unfortunately not many great options

isPaymentInitiator
isMoneySender

Copy link
Contributor Author

@tienifr tienifr May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, @thienlnam. Just a little clear-up because I'm messed up myself between payer and payee; manager and owner right now 😅:

Note: A initiated the actions.

Action owner manager payer payee
Request A B B A
Send B A A B

Payer is the one who pays; while payee is the one to whom money is paid. In which ever case, the manager is the payer.

In addition, I spotted another place where isPayer is used:

const isPayer = Policy.isAdminOfFreePolicy([policy]) || (ReportUtils.isMoneyRequestReport(props.report) && lodashGet(props.session, 'email', null) === props.report.managerEmail);
const shouldShowSettlementButton = !isSettled && !props.isSingleTransactionView && isPayer;

Therefore, I think isPayer is appropriate here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

* @returns {Array<*>}
*/
function getIcons(report, personalDetails, defaultIcon = null) {
function getIcons(report, personalDetails, defaultIcon = null, isPayer = false) {
const result = {
source: '',
type: CONST.ICON_TYPE_AVATAR,
Expand Down Expand Up @@ -924,10 +925,11 @@ function getIcons(report, personalDetails, defaultIcon = null) {
return [adminIcon, workspaceIcon];
}
if (isIOUReport(report)) {
const email = isPayer ? report.managerEmail : report.ownerEmail;
return [
{
source: getAvatar(lodashGet(personalDetails, [report.ownerEmail, 'avatar']), report.ownerEmail),
name: report.ownerEmail,
source: getAvatar(lodashGet(personalDetails, [email, 'avatar']), email),
name: email,
type: CONST.ICON_TYPE_AVATAR,
},
];
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function getOptionData(reportID) {
result.subtitle = subtitle;
result.participantsList = participantPersonalDetailList;

result.icons = ReportUtils.getIcons(result.isTaskReport ? parentReport : report, personalDetails, policies, ReportUtils.getAvatar(personalDetail.avatar, personalDetail.login));
result.icons = ReportUtils.getIcons(result.isTaskReport ? parentReport : report, personalDetails, ReportUtils.getAvatar(personalDetail.avatar, personalDetail.login), true);
result.searchText = OptionsListUtils.getSearchText(report, reportName, participantPersonalDetailList, result.isChatRoom || result.isPolicyExpenseChat);
result.displayNamesWithTooltips = displayNamesWithTooltips;
return result;
Expand Down