diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index b17fe7266079..74b6d0fd37fe 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1960,7 +1960,7 @@ function getIcons( if (isChatThread(report)) { const parentReportAction = ReportActionsUtils.getParentReportAction(report); - const actorAccountID = parentReportAction?.actorAccountID; + const actorAccountID = getReportActionActorAccountID(parentReportAction, report); const actorDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(allPersonalDetails?.[actorAccountID ?? -1], '', false); const actorIcon = { id: actorAccountID, @@ -3953,77 +3953,11 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa return expenseReport; } -function getIOUSubmittedMessage(report: OnyxEntry) { - const policy = getPolicy(report?.policyID); - - if (report?.ownerAccountID !== currentUserAccountID && policy?.role === CONST.POLICY.ROLE.ADMIN) { - const ownerPersonalDetail = getPersonalDetailsForAccountID(report?.ownerAccountID ?? -1); - const ownerDisplayName = `${ownerPersonalDetail.displayName ?? ''}${ownerPersonalDetail.displayName !== ownerPersonalDetail.login ? ` (${ownerPersonalDetail.login})` : ''}`; - - return [ - { - style: 'normal', - text: 'You (on behalf of ', - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - }, - { - style: 'strong', - text: ownerDisplayName, - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - }, - { - style: 'normal', - text: ' via admin-submit)', - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - }, - { - style: 'normal', - text: ' submitted this report', - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - }, - { - style: 'normal', - text: ' to ', - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - }, - { - style: 'strong', - text: 'you', - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - }, - ]; - } - - const submittedToPersonalDetail = getPersonalDetailsForAccountID(PolicyUtils.getSubmitToAccountID(policy, report?.ownerAccountID ?? 0)); - let submittedToDisplayName = `${submittedToPersonalDetail.displayName ?? ''}${ - submittedToPersonalDetail.displayName !== submittedToPersonalDetail.login ? ` (${submittedToPersonalDetail.login})` : '' - }`; - if (submittedToPersonalDetail?.accountID === currentUserAccountID) { - submittedToDisplayName = 'yourself'; - } - - return [ - { - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - style: 'strong', - text: 'You', - }, - { - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - style: 'normal', - text: ' submitted this report', - }, - { - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - style: 'normal', - text: ' to ', - }, - { - type: CONST.REPORT.MESSAGE.TYPE.TEXT, - style: 'strong', - text: submittedToDisplayName, - }, - ]; +function getIOUSubmittedMessage(reportID: string) { + const report = getReportOrDraftReport(reportID); + const linkedReport = isChatThread(report) ? getParentReport(report) : report; + const formattedAmount = CurrencyUtils.convertToDisplayString(Math.abs(linkedReport?.total ?? 0), linkedReport?.currency); + return Localize.translateLocal('iou.submittedAmount', {formattedAmount}); } /** @@ -4037,11 +3971,6 @@ function getIOUSubmittedMessage(report: OnyxEntry) { */ function getIOUReportActionMessage(iouReportID: string, type: string, total: number, comment: string, currency: string, paymentType = '', isSettlingUp = false): Message[] { const report = getReportOrDraftReport(iouReportID); - - if (type === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { - return getIOUSubmittedMessage(!isEmptyObject(report) ? report : undefined); - } - const amount = type === CONST.IOU.REPORT_ACTION_TYPE.PAY && !isEmptyObject(report) ? CurrencyUtils.convertToDisplayString(getMoneyRequestSpendBreakdown(report).totalDisplaySpend, currency) @@ -4078,6 +4007,9 @@ function getIOUReportActionMessage(iouReportID: string, type: string, total: num case CONST.IOU.REPORT_ACTION_TYPE.PAY: iouMessage = isSettlingUp ? `paid ${amount}${paymentMethodMessage}` : `sent ${amount}${comment && ` for ${comment}`}${paymentMethodMessage}`; break; + case CONST.REPORT.ACTIONS.TYPE.SUBMITTED: + iouMessage = Localize.translateLocal('iou.submittedAmount', {formattedAmount: amount}); + break; default: break; } @@ -7129,6 +7061,7 @@ export { getGroupChatName, getIOUReportActionDisplayMessage, getIOUReportActionMessage, + getIOUSubmittedMessage, getIcons, getIconsForParticipants, getIndicatedMissingPaymentMethod, diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index bf634b4ac8ae..7102c9878dca 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -396,6 +396,9 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(mentionWhisperMessage); } else if (ReportActionsUtils.isActionableTrackExpense(reportAction)) { setClipboardMessage(CONST.ACTIONABLE_TRACK_EXPENSE_WHISPER_MESSAGE); + } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { + const displayMessage = ReportUtils.getIOUSubmittedMessage(reportID); + Clipboard.setString(displayMessage); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { Clipboard.setString(Localize.translateLocal('iou.heldExpense')); } else if (reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index 2264feddd679..f0b36667e1dd 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -616,6 +616,8 @@ function ReportActionItem({ } else if (ReportActionsUtils.isOldDotReportAction(action)) { // This handles all historical actions from OldDot that we just want to display the message text children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) { + children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) { children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) {