diff --git a/src/components/ReportActionItem/IOUPreview.js b/src/components/ReportActionItem/IOUPreview.js index a63aaca4ff88..0f538b74326a 100644 --- a/src/components/ReportActionItem/IOUPreview.js +++ b/src/components/ReportActionItem/IOUPreview.js @@ -137,7 +137,7 @@ const IOUPreview = (props) => { // When displaying within a IOUDetailsModal we cannot guarantee that participants are included in the originalMessage data // Because an IOUPreview of type split can never be rendered within the IOUDetailsModal, manually building the email array is only needed for non-billSplit ious - const participantEmails = props.isBillSplit ? props.action.originalMessage.participants : [managerEmail, ownerEmail]; + const participantEmails = props.isBillSplit ? lodashGet(props.action, 'originalMessage.participants', []) : [managerEmail, ownerEmail]; const participantAvatars = OptionsListUtils.getAvatarsForLogins(participantEmails, props.personalDetails); // Pay button should only be visible to the manager of the report. diff --git a/src/components/ReportActionItem/ReportPreview.js b/src/components/ReportActionItem/ReportPreview.js index 24f209ff20c4..b643d2ae606b 100644 --- a/src/components/ReportActionItem/ReportPreview.js +++ b/src/components/ReportActionItem/ReportPreview.js @@ -36,6 +36,15 @@ const propTypes = { // eslint-disable-next-line react/no-unused-prop-types iouReportID: PropTypes.string.isRequired, + /** chatReport associated with iouReport */ + chatReport: PropTypes.shape({ + /** The participants of this report */ + participants: PropTypes.arrayOf(PropTypes.string), + + /** Whether the chat report has an outstanding IOU */ + hasOutstandingIOU: PropTypes.bool.isRequired, + }), + /** Active IOU Report for current report */ iouReport: PropTypes.shape({ /** Email address of the manager in this iou report */ @@ -78,6 +87,7 @@ const propTypes = { const defaultProps = { contextMenuAnchor: null, isHovered: false, + chatReport: {}, iouReport: {}, onViewDetailsPressed: () => {}, checkIfContextMenuActive: () => {}, @@ -89,7 +99,7 @@ const defaultProps = { const ReportPreview = (props) => { const reportAmount = CurrencyUtils.convertToDisplayString(ReportUtils.getMoneyRequestTotal(props.iouReport), props.iouReport.currency); const managerEmail = props.iouReport.managerEmail || ''; - const managerName = ReportUtils.getDisplayNameForParticipant(managerEmail, true); + const managerName = ReportUtils.isPolicyExpenseChat(props.chatReport) ? ReportUtils.getPolicyName(props.chatReport) : ReportUtils.getDisplayNameForParticipant(managerEmail, true); const isCurrentUserManager = managerEmail === lodashGet(props.session, 'email', null); return ( @@ -149,6 +159,9 @@ ReportPreview.displayName = 'ReportPreview'; export default compose( withLocalize, withOnyx({ + chatReport: { + key: ({chatReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${chatReportID}`, + }, iouReport: { key: ({iouReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${iouReportID}`, }, diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index bf5f0a21fe88..37fc0b8b3fe2 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -88,9 +88,9 @@ const ReportActionItemSingle = (props) => { {props.shouldShowSubscriptAvatar ? ( ) : (