diff --git a/src/components/ReportActionItem/TaskAction.js b/src/components/ReportActionItem/TaskAction.js
index 1406c78956f7..90483e9dff3b 100644
--- a/src/components/ReportActionItem/TaskAction.js
+++ b/src/components/ReportActionItem/TaskAction.js
@@ -1,32 +1,23 @@
import React from 'react';
-import {View, Pressable} from 'react-native';
+import {View} from 'react-native';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
-import Navigation from '../../libs/Navigation/Navigation';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
-import ROUTES from '../../ROUTES';
import compose from '../../libs/compose';
import ONYXKEYS from '../../ONYXKEYS';
import Text from '../Text';
import styles from '../../styles/styles';
-import Icon from '../Icon';
-import * as Expensicons from '../Icon/Expensicons';
-import * as StyleUtils from '../../styles/StyleUtils';
-import getButtonState from '../../libs/getButtonState';
import CONST from '../../CONST';
const propTypes = {
- /** The ID of the associated taskReport */
- taskReportID: PropTypes.string.isRequired,
-
- /** Whether the task preview is hovered so we can modify its style */
- isHovered: PropTypes.bool,
-
/** Name of the reportAction action */
actionName: PropTypes.string.isRequired,
- /* Onyx Props */
+ /** 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,
+ /* Onyx Props */
taskReport: PropTypes.shape({
/** Title of the task */
reportName: PropTypes.string,
@@ -43,10 +34,8 @@ const propTypes = {
const defaultProps = {
taskReport: {},
- isHovered: false,
};
const TaskAction = (props) => {
- const taskReportID = props.taskReportID;
const taskReportName = props.taskReport.reportName || '';
let messageLinkText = '';
@@ -65,19 +54,12 @@ const TaskAction = (props) => {
}
return (
- Navigation.navigate(ROUTES.getReportRoute(taskReportID))}
- style={[styles.flexRow, styles.justifyContentBetween]}
- >
+ <>
{messageLinkText}
{` ${taskReportName}`}
-
-
+ >
);
};
diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js
index 5755dcaf6663..3f66c211d476 100644
--- a/src/components/ReportActionItem/TaskPreview.js
+++ b/src/components/ReportActionItem/TaskPreview.js
@@ -53,13 +53,12 @@ const TaskPreview = (props) => {
// The reportAction might not contain details regarding the taskReport
// Only the direct parent reportAction will contain details about the taskReport
// Other linked reportActions will only contain the taskReportID and we will grab the details from there
- const isTaskCompleted =
- (props.taskReport.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && props.taskReport.statusNum === CONST.REPORT.STATUS.APPROVED) ||
- (props.action.childStateNum === CONST.REPORT.STATE_NUM.SUBMITTED && props.action.childStatusNum === CONST.REPORT.STATUS.APPROVED);
+ const isTaskCompleted = props.taskReport
+ ? props.taskReport.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && props.taskReport.statusNum === CONST.REPORT.STATUS.APPROVED
+ : props.action.childStateNum === CONST.REPORT.STATE_NUM.SUBMITTED && props.action.childStatusNum === CONST.REPORT.STATUS.APPROVED;
const taskTitle = props.taskReport.reportName || props.action.childReportName;
const taskAssignee = props.taskReport.managerEmail || props.action.childManagerEmail;
const htmlForTaskPreview = taskAssignee ? `@${taskAssignee} ${taskTitle}` : `${taskTitle}`;
- const parentReportID = props.taskReport.parentReportID || props.action.parentReportID;
return (
{
disabled={TaskUtils.isTaskCanceled(props.taskReport)}
onPress={() => {
if (isTaskCompleted) {
- TaskUtils.reopenTask(props.taskReportID, parentReportID, taskTitle);
+ TaskUtils.reopenTask(props.taskReportID, taskTitle);
} else {
- TaskUtils.completeTask(props.taskReportID, parentReportID, taskTitle);
+ TaskUtils.completeTask(props.taskReportID, taskTitle);
}
}}
/>
diff --git a/src/components/TaskHeader.js b/src/components/TaskHeader.js
index 4cf8e44254d2..2a6d62183954 100644
--- a/src/components/TaskHeader.js
+++ b/src/components/TaskHeader.js
@@ -40,7 +40,6 @@ function TaskHeader(props) {
const assigneeAvatar = UserUtils.getAvatar(lodashGet(props.personalDetails, [props.report.managerEmail, 'avatar']), props.report.managerEmail);
const isOpen = props.report.stateNum === CONST.REPORT.STATE_NUM.OPEN && props.report.statusNum === CONST.REPORT.STATUS.OPEN;
const isCompleted = props.report.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum === CONST.REPORT.STATUS.APPROVED;
- const parentReportID = props.report.parentReportID;
useEffect(() => {
TaskUtils.setTaskReport(props.report);
@@ -97,7 +96,7 @@ function TaskHeader(props) {
isDisabled={TaskUtils.isTaskCanceled(props.report)}
medium
text={props.translate('newTaskPage.markAsDone')}
- onPress={() => TaskUtils.completeTask(props.report.reportID, parentReportID, title)}
+ onPress={() => TaskUtils.completeTask(props.report.reportID, title)}
/>
)}
diff --git a/src/languages/en.js b/src/languages/en.js
index 2e374a33dbfa..fa3fc5b23b05 100755
--- a/src/languages/en.js
+++ b/src/languages/en.js
@@ -1273,9 +1273,9 @@ export default {
task: {
completed: 'Completed',
messages: {
- completed: 'Completed task',
- canceled: 'Canceled task',
- reopened: 'Reopened task',
+ completed: 'completed task',
+ canceled: 'canceled task',
+ reopened: 'reopened task',
},
},
statementPage: {
diff --git a/src/languages/es.js b/src/languages/es.js
index 889da7379e5f..a06292495d1c 100644
--- a/src/languages/es.js
+++ b/src/languages/es.js
@@ -1279,9 +1279,9 @@ export default {
task: {
completed: 'Completada',
messages: {
- completed: 'Tarea completada',
- canceled: 'Tarea cancelada',
- reopened: 'Tarea reabrir',
+ completed: 'tarea completada',
+ canceled: 'tarea cancelada',
+ reopened: 'tarea reabrir',
},
},
statementPage: {
diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js
index 4ee4428fcb82..b5c53368e489 100644
--- a/src/libs/actions/Task.js
+++ b/src/libs/actions/Task.js
@@ -170,8 +170,8 @@ function createTaskAndNavigate(currentUserEmail, parentReportID, title, descript
Navigation.navigate(ROUTES.getReportRoute(optimisticTaskReport.reportID));
}
-function completeTask(taskReportID, parentReportID, taskTitle) {
- const message = `Completed task: ${taskTitle}`;
+function completeTask(taskReportID, taskTitle) {
+ const message = `completed task: ${taskTitle}`;
const completedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED, message);
const optimisticData = [
@@ -183,18 +183,10 @@ function completeTask(taskReportID, parentReportID, taskTitle) {
statusNum: CONST.REPORT.STATUS.APPROVED,
},
},
+
{
onyxMethod: Onyx.METHOD.MERGE,
- key: `${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`,
- value: {
- lastVisibleActionCreated: completedTaskReportAction.created,
- lastMessageText: message,
- lastActorEmail: completedTaskReportAction.actorEmail,
- },
- },
- {
- onyxMethod: Onyx.METHOD.MERGE,
- key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`,
+ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`,
value: {[completedTaskReportAction.reportActionID]: completedTaskReportAction},
},
];
@@ -211,7 +203,7 @@ function completeTask(taskReportID, parentReportID, taskTitle) {
},
{
onyxMethod: Onyx.METHOD.MERGE,
- key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`,
+ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`,
value: {[completedTaskReportAction.reportActionID]: {pendingAction: null}},
},
];
@@ -229,11 +221,10 @@ function completeTask(taskReportID, parentReportID, taskTitle) {
/**
* Reopens a closed task
* @param {string} taskReportID ReportID of the task
- * @param {string} parentReportID ReportID of the linked parent report of the task so we can add the action
* @param {string} taskTitle Title of the task
*/
-function reopenTask(taskReportID, parentReportID, taskTitle) {
- const message = `Reopened task: ${taskTitle}`;
+function reopenTask(taskReportID, taskTitle) {
+ const message = `reopened task: ${taskTitle}`;
const reopenedTaskReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASKREOPENED, message);
const optimisticData = [
@@ -243,20 +234,15 @@ function reopenTask(taskReportID, parentReportID, taskTitle) {
value: {
stateNum: CONST.REPORT.STATE_NUM.OPEN,
statusNum: CONST.REPORT.STATUS.OPEN,
- },
- },
- {
- onyxMethod: Onyx.METHOD.MERGE,
- key: `${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`,
- value: {
lastVisibleActionCreated: reopenedTaskReportAction.created,
lastMessageText: message,
lastActorEmail: reopenedTaskReportAction.actorEmail,
+ lastReadTime: reopenedTaskReportAction.created,
},
},
{
onyxMethod: Onyx.METHOD.MERGE,
- key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`,
+ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`,
value: {[reopenedTaskReportAction.reportActionID]: reopenedTaskReportAction},
},
];
@@ -273,7 +259,7 @@ function reopenTask(taskReportID, parentReportID, taskTitle) {
},
{
onyxMethod: Onyx.METHOD.MERGE,
- key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`,
+ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`,
value: {[reopenedTaskReportAction.reportActionID]: {pendingAction: null}},
},
];
@@ -526,13 +512,12 @@ function getShareDestination(reportID, reports, personalDetails) {
/**
* Cancels a task by setting the report state to SUBMITTED and status to CLOSED
* @param {string} taskReportID
- * @param {string} parentReportID
* @param {string} taskTitle
* @param {number} originalStateNum
* @param {number} originalStatusNum
*/
-function cancelTask(taskReportID, parentReportID, taskTitle, originalStateNum, originalStatusNum) {
- const message = `Canceled task: ${taskTitle}`;
+function cancelTask(taskReportID, taskTitle, originalStateNum, originalStatusNum) {
+ const message = `canceled task: ${taskTitle}`;
const optimisticCancelReportAction = ReportUtils.buildOptimisticTaskReportAction(taskReportID, CONST.REPORT.ACTIONS.TYPE.TASKCANCELED, message);
const optimisticReportActionID = optimisticCancelReportAction.reportActionID;
@@ -547,7 +532,7 @@ function cancelTask(taskReportID, parentReportID, taskTitle, originalStateNum, o
},
{
onyxMethod: Onyx.METHOD.MERGE,
- key: `${ONYXKEYS.COLLECTION.REPORT}${parentReportID}`,
+ key: `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`,
value: {
lastVisibleActionCreated: optimisticCancelReportAction.created,
lastMessageText: message,
@@ -556,7 +541,7 @@ function cancelTask(taskReportID, parentReportID, taskTitle, originalStateNum, o
},
{
onyxMethod: Onyx.METHOD.MERGE,
- key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`,
+ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`,
value: {
[optimisticReportActionID]: optimisticCancelReportAction,
},
@@ -574,7 +559,7 @@ function cancelTask(taskReportID, parentReportID, taskTitle, originalStateNum, o
},
{
onyxMethod: Onyx.METHOD.MERGE,
- key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID}`,
+ key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${taskReportID}`,
value: {
[optimisticReportActionID]: null,
},
diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js
index 73cc0fc4a535..c6f312574394 100644
--- a/src/pages/home/HeaderView.js
+++ b/src/pages/home/HeaderView.js
@@ -92,7 +92,7 @@ const HeaderView = (props) => {
threeDotMenuItems.push({
icon: Expensicons.Checkmark,
text: props.translate('newTaskPage.markAsDone'),
- onSelected: () => Task.completeTask(props.report.reportID, props.report.parentReportID, title),
+ onSelected: () => Task.completeTask(props.report.reportID, title),
});
}
@@ -101,7 +101,7 @@ const HeaderView = (props) => {
threeDotMenuItems.push({
icon: Expensicons.Checkmark,
text: props.translate('newTaskPage.markAsIncomplete'),
- onSelected: () => Task.reopenTask(props.report.reportID, props.report.parentReportID, title),
+ onSelected: () => Task.reopenTask(props.report.reportID, title),
});
}
@@ -110,7 +110,7 @@ const HeaderView = (props) => {
threeDotMenuItems.push({
icon: Expensicons.Trashcan,
text: props.translate('common.cancel'),
- onSelected: () => Task.cancelTask(props.report.reportID, props.report.parentReportID, props.report.reportName, props.report.stateNum, props.report.statusNum),
+ onSelected: () => Task.cancelTask(props.report.reportID, props.report.reportName, props.report.stateNum, props.report.statusNum),
});
}
}
diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js
index 03eb9407b8dc..273c59eb03d9 100644
--- a/src/pages/home/report/ReportActionItem.js
+++ b/src/pages/home/report/ReportActionItem.js
@@ -232,7 +232,6 @@ function ReportActionItem(props) {
);
} else if (ReportActionsUtils.isCreatedTaskReportAction(props.action)) {