diff --git a/src/components/ReportActionItem/TaskAction.js b/src/components/ReportActionItem/TaskAction.js
index c5d17605d331..da86d36a49f2 100644
--- a/src/components/ReportActionItem/TaskAction.js
+++ b/src/components/ReportActionItem/TaskAction.js
@@ -7,9 +7,12 @@ import compose from '../../libs/compose';
import ONYXKEYS from '../../ONYXKEYS';
import Text from '../Text';
import styles from '../../styles/styles';
-import getTaskReportActionMessage from '../../libs/getTaskReportActionMessage';
+import * as ReportActionUtils from '../../libs/ReportActionsUtils';
const propTypes = {
+ /** Name of the reportAction action */
+ actionName: PropTypes.string.isRequired,
+
/** The ID of the associated taskReport */
// eslint-disable-next-line react/no-unused-prop-types -- This is used in the withOnyx HOC
taskReportID: PropTypes.string.isRequired,
@@ -36,7 +39,7 @@ function TaskAction(props) {
return (
<>
- {getTaskReportActionMessage(props.reportAction, props.translate)}
+ {ReportActionUtils.getTaskReportActionMessage(props.actionName, props.taskReportID)}
>
);
diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js
index 9cbc414bf582..bab587457b94 100644
--- a/src/libs/ReportActionsUtils.js
+++ b/src/libs/ReportActionsUtils.js
@@ -9,6 +9,7 @@ import CONST from '../CONST';
import ONYXKEYS from '../ONYXKEYS';
import Log from './Log';
import isReportMessageAttachment from './isReportMessageAttachment';
+import * as Localize from './Localize';
const allReports = {};
Onyx.connect({
@@ -612,6 +613,30 @@ function getAllReportActions(reportID) {
return lodashGet(allReportActions, reportID, []);
}
+/**
+ * @param {string} actionName
+ * @param {string} reportID
+ * @returns {string}
+ */
+function getTaskReportActionMessage(actionName, reportID) {
+ let taskStatusText = '';
+ switch (actionName) {
+ case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED:
+ taskStatusText = Localize.translateLocal('task.messages.completed');
+ break;
+ case CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED:
+ taskStatusText = Localize.translateLocal('task.messages.canceled');
+ break;
+ case CONST.REPORT.ACTIONS.TYPE.TASKREOPENED:
+ taskStatusText = Localize.translateLocal('task.messages.reopened');
+ break;
+ default:
+ taskStatusText = Localize.translateLocal('task.task');
+ }
+
+ return `${taskStatusText} ${allReports[reportID].reportName}`;
+}
+
export {
getSortedReportActions,
getLastVisibleAction,
@@ -649,4 +674,5 @@ export {
isSplitBillAction,
isTaskAction,
getAllReportActions,
+ getTaskReportActionMessage,
};
diff --git a/src/libs/getTaskReportActionMessage.js b/src/libs/getTaskReportActionMessage.js
deleted file mode 100644
index 8c7d168566f6..000000000000
--- a/src/libs/getTaskReportActionMessage.js
+++ /dev/null
@@ -1,29 +0,0 @@
-import CONST from '../CONST';
-import * as ReportUtils from './ReportUtils';
-/**
- * @param {Object} reportAction
- * @param {Function} translate
- * @returns {string}
- */
-function getTaskReportActionMessage(reportAction, translate) {
- const taskReport = ReportUtils.getReport(reportAction.originalMessage.taskReportID.toString());
- const taskReportName = taskReport.reportName || '';
-
- let taskStatusText = '';
- switch (reportAction.actionName) {
- case CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED:
- taskStatusText = translate('task.messages.completed');
- break;
- case CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED:
- taskStatusText = translate('task.messages.canceled');
- break;
- case CONST.REPORT.ACTIONS.TYPE.TASKREOPENED:
- taskStatusText = translate('task.messages.reopened');
- break;
- default:
- taskStatusText = translate('task.task');
- }
- return `${taskStatusText} ${taskReportName}`;
-}
-
-export default getTaskReportActionMessage;
diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js
index d87481e9e5f7..362ce23f72ba 100755
--- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js
+++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js
@@ -92,7 +92,6 @@ function BaseReportActionContextMenu(props) {
close: () => setShouldKeepOpen(false),
openContextMenu: () => setShouldKeepOpen(true),
interceptAnonymousUser,
- translate: props.translate,
};
if (contextAction.renderContent) {
diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js
index 56e02ec5a333..5745d01a8bfe 100644
--- a/src/pages/home/report/ContextMenu/ContextMenuActions.js
+++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js
@@ -21,7 +21,6 @@ import QuickEmojiReactions from '../../../../components/Reactions/QuickEmojiReac
import MiniQuickEmojiReactions from '../../../../components/Reactions/MiniQuickEmojiReactions';
import Navigation from '../../../../libs/Navigation/Navigation';
import ROUTES from '../../../../ROUTES';
-import getTaskReportActionMessage from '../../../../libs/getTaskReportActionMessage';
/**
* Gets the HTML version of the message in an action.
@@ -183,11 +182,11 @@ export default [
// If return value is true, we switch the `text` and `icon` on
// `ContextMenuItem` with `successText` and `successIcon` which will fallback to
// the `text` and `icon`
- onPress: (closePopover, {reportAction, selection, translate}) => {
+ onPress: (closePopover, {reportAction, selection, reportID}) => {
const isTaskAction = ReportActionsUtils.isTaskAction(reportAction);
const isReportPreviewAction = ReportActionsUtils.isReportPreviewAction(reportAction);
const message = _.last(lodashGet(reportAction, 'message', [{}]));
- const messageHtml = isTaskAction ? getTaskReportActionMessage(reportAction, translate) : lodashGet(message, 'html', '');
+ const messageHtml = isTaskAction ? ReportActionsUtils.getTaskReportActionMessage(reportAction.actionName, reportID) : lodashGet(message, 'html', '');
const isAttachment = _.has(reportAction, 'isAttachment') ? reportAction.isAttachment : ReportUtils.isReportMessageAttachment(message);
if (!isAttachment) {
diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js
index 2b79e464fa55..22ded971898f 100644
--- a/src/pages/home/report/ReportActionItem.js
+++ b/src/pages/home/report/ReportActionItem.js
@@ -296,7 +296,12 @@ function ReportActionItem(props) {
props.action.actionName === CONST.REPORT.ACTIONS.TYPE.TASKCANCELLED ||
props.action.actionName === CONST.REPORT.ACTIONS.TYPE.TASKREOPENED
) {
- children = ;
+ children = (
+
+ );
} else if (ReportActionsUtils.isCreatedTaskReportAction(props.action)) {
children = (