Skip to content

Commit

Permalink
Check if current user is isPayer via report object
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangzinh committed Sep 21, 2023
1 parent b225b53 commit fe29843
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/AvatarWithDisplayName.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function AvatarWithDisplayName(props) {
const subtitle = ReportUtils.getChatRoomSubtitle(props.report);
const parentNavigationSubtitleData = ReportUtils.getParentNavigationSubtitle(props.report);
const isMoneyRequestOrReport = ReportUtils.isMoneyRequestReport(props.report) || ReportUtils.isMoneyRequest(props.report);
const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policy, true);
const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policy);
const ownerPersonalDetails = OptionsListUtils.getPersonalDetailsForAccountIDs([props.report.ownerAccountID], props.personalDetails);
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips(_.values(ownerPersonalDetails), false);
const shouldShowSubscriptAvatar = ReportUtils.shouldReportShowSubscript(props.report);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {

result.text = reportName;
result.searchText = getSearchText(report, reportName, personalDetailList, result.isChatRoom || result.isPolicyExpenseChat, result.isThread);
result.icons = ReportUtils.getIcons(report, personalDetails, UserUtils.getAvatar(personalDetail.avatar, personalDetail.accountID), false, personalDetail.login, personalDetail.accountID);
result.icons = ReportUtils.getIcons(report, personalDetails, UserUtils.getAvatar(personalDetail.avatar, personalDetail.accountID), personalDetail.login, personalDetail.accountID);
result.subtitle = subtitle;

return result;
Expand Down
5 changes: 2 additions & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,13 +999,12 @@ function getWorkspaceIcon(report, policy = undefined) {
* @param {Object} report
* @param {Object} personalDetails
* @param {*} [defaultIcon]
* @param {Boolean} [isPayer]
* @param {String} [defaultName]
* @param {Number} [defaultAccountID]
* @param {Object} [policy]
* @returns {Array<*>}
*/
function getIcons(report, personalDetails, defaultIcon = null, isPayer = false, defaultName = '', defaultAccountID = -1, policy = undefined) {
function getIcons(report, personalDetails, defaultIcon = null, defaultName = '', defaultAccountID = -1, policy = undefined) {
if (_.isEmpty(report)) {
const fallbackIcon = {
source: defaultIcon || Expensicons.FallbackAvatar,
Expand Down Expand Up @@ -1093,13 +1092,13 @@ function getIcons(report, personalDetails, defaultIcon = null, isPayer = false,
type: CONST.ICON_TYPE_AVATAR,
name: lodashGet(personalDetails, [report.managerID, 'displayName'], ''),
};

const ownerIcon = {
id: report.ownerAccountID,
source: UserUtils.getAvatar(lodashGet(personalDetails, [report.ownerAccountID, 'avatar']), report.ownerAccountID),
type: CONST.ICON_TYPE_AVATAR,
name: lodashGet(personalDetails, [report.ownerAccountID, 'displayName'], ''),
};
const isPayer = currentUserAccountID === report.managerID;

return isPayer ? [managerIcon, ownerIcon] : [ownerIcon, managerIcon];
}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ function getOptionData(report, reportActions, personalDetails, preferredLocale,
result.subtitle = subtitle;
result.participantsList = participantPersonalDetailList;

result.icons = ReportUtils.getIcons(report, personalDetails, UserUtils.getAvatar(personalDetail.avatar, personalDetail.accountID), true, '', -1, policy);
result.icons = ReportUtils.getIcons(report, personalDetails, UserUtils.getAvatar(personalDetail.avatar, personalDetail.accountID), '', -1, policy);
result.searchText = OptionsListUtils.getSearchText(report, reportName, participantPersonalDetailList, result.isChatRoom || result.isPolicyExpenseChat, result.isThread);
result.displayNamesWithTooltips = displayNamesWithTooltips;
result.isLastMessageDeletedParentAction = report.isLastMessageDeletedParentAction;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ function getShareDestination(reportID, reports, personalDetails) {
subtitle = ReportUtils.getChatRoomSubtitle(report);
}
return {
icons: ReportUtils.getIcons(report, personalDetails, Expensicons.FallbackAvatar, ReportUtils.isIOUReport(report)),
icons: ReportUtils.getIcons(report, personalDetails, Expensicons.FallbackAvatar),
displayName: ReportUtils.getReportName(report),
subtitle,
};
Expand Down

0 comments on commit fe29843

Please sign in to comment.