Skip to content

Commit

Permalink
Merge pull request #37177 from FitseTLT/fix-concierge-auto-approval-r…
Browse files Browse the repository at this point in the history
…eport-action-bug

Fix - "Concierge" is displayed in LHN and thread header for Concierge approval message
  • Loading branch information
Gonals authored Mar 4, 2024
2 parents 5a6d2e5 + 5ed8601 commit 0b447c3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,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 @@ -2539,7 +2539,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

0 comments on commit 0b447c3

Please sign in to comment.