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
2 changes: 2 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
lastMessageTextFromReport = lastReportAction?.message?.[0].text ?? '';
} else if (ReportActionUtils.isCreatedTaskReportAction(lastReportAction)) {
lastMessageTextFromReport = TaskUtils.getTaskCreatedMessage(lastReportAction);
} else if (ReportActionUtils.isApprovedOrSubmittedReportAction(lastReportAction)) {
lastMessageTextFromReport = ReportActionUtils.getReportActionMessageText(lastReportAction);
}

return lastMessageTextFromReport || (report?.lastMessageText ?? '');
Expand Down
13 changes: 13 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,17 @@ function isCurrentActionUnread(report: Report | EmptyObject, reportAction: Repor
return isReportActionUnread(reportAction, lastReadTime) && (!prevReportAction || !isReportActionUnread(prevReportAction, lastReadTime));
}

function isApprovedOrSubmittedReportAction(action: OnyxEntry<ReportAction> | EmptyObject) {
return [CONST.REPORT.ACTIONS.TYPE.APPROVED, CONST.REPORT.ACTIONS.TYPE.SUBMITTED].some((type) => type === action?.actionName);
}

/**
* Gets the text version of the message in a report action
*/
function getReportActionMessageText(reportAction: OnyxEntry<ReportAction> | EmptyObject): string {
return reportAction?.message?.reduce((acc, curr) => `${acc}${curr.text}`, '') ?? '';
}

export {
extractLinksFromMessageHtml,
getAllReportActions,
Expand All @@ -898,6 +909,8 @@ export {
getNumberOfMoneyRequests,
getParentReportAction,
getReportAction,
getReportActionMessageText,
isApprovedOrSubmittedReportAction,
getReportPreviewAction,
getSortedReportActions,
getSortedReportActionsForDisplay,
Expand Down
6 changes: 5 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2511,7 +2511,11 @@ function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = nu
}

const isAttachment = ReportActionsUtils.isReportActionAttachment(!isEmptyObject(parentReportAction) ? parentReportAction : null);
const parentReportActionMessage = (parentReportAction?.message?.[0]?.text ?? '').replace(/(\r\n|\n|\r)/gm, ' ');
const parentReportActionMessage = (
ReportActionsUtils.isApprovedOrSubmittedReportAction(parentReportAction)
? ReportActionsUtils.getReportActionMessageText(parentReportAction)
: parentReportAction?.message?.[0]?.text ?? ''
).replace(/(\r\n|\n|\r)/gm, ' ');
if (isAttachment && parentReportActionMessage) {
return `[${Localize.translateLocal('common.attachment')}]`;
}
Expand Down
7 changes: 1 addition & 6 deletions src/pages/home/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ function getActionHtml(reportAction: OnyxEntry<ReportAction>): string {
return message?.html ?? '';
}

/** Gets the text version of the message in an action */
function getActionText(reportAction: OnyxEntry<ReportAction>): string {
return reportAction?.message?.reduce((acc, curr) => `${acc}${curr.text}`, '') ?? '';
}

/** Sets the HTML string to Clipboard */
function setClipboardMessage(content: string) {
const parser = new ExpensiMark();
Expand Down Expand Up @@ -341,7 +336,7 @@ const ContextMenuActions: ContextMenuAction[] = [
const isTaskAction = ReportActionsUtils.isTaskAction(reportAction);
const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction);
const messageHtml = isTaskAction ? TaskUtils.getTaskReportActionMessage(reportAction?.actionName) : getActionHtml(reportAction);
const messageText = getActionText(reportAction);
const messageText = ReportActionsUtils.getReportActionMessageText(reportAction);

const isAttachment = ReportActionsUtils.isReportActionAttachment(reportAction);
if (!isAttachment) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItemMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHid
}
}

const isApprovedOrSubmittedReportAction = [CONST.REPORT.ACTIONS.TYPE.APPROVED, CONST.REPORT.ACTIONS.TYPE.SUBMITTED].some((type) => type === action.actionName);
const isApprovedOrSubmittedReportAction = ReportActionsUtils.isApprovedOrSubmittedReportAction(action);

const isHoldReportAction = [CONST.REPORT.ACTIONS.TYPE.HOLD, CONST.REPORT.ACTIONS.TYPE.UNHOLD].some((type) => type === action.actionName);

Expand Down