Skip to content
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
87 changes: 10 additions & 77 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -3953,77 +3953,11 @@ function buildOptimisticExpenseReport(chatReportID: string, policyID: string, pa
return expenseReport;
}

function getIOUSubmittedMessage(report: OnyxEntry<Report>) {
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});
}

/**
Expand All @@ -4037,11 +3971,6 @@ function getIOUSubmittedMessage(report: OnyxEntry<Report>) {
*/
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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -7129,6 +7061,7 @@ export {
getGroupChatName,
getIOUReportActionDisplayMessage,
getIOUReportActionMessage,
getIOUSubmittedMessage,
getIcons,
getIconsForParticipants,
getIndicatedMissingPaymentMethod,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <ReportActionItemBasicMessage message={ReportActionsUtils.getMessageOfOldDotReportAction(action)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.SUBMITTED) {
children = <ReportActionItemBasicMessage message={ReportUtils.getIOUSubmittedMessage(report.reportID)} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD) {
children = <ReportActionItemBasicMessage message={translate('iou.heldExpense')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.HOLD_COMMENT) {
Expand Down