From 4a17c1bc53788c39654f40b6b8918f723bf4d9de Mon Sep 17 00:00:00 2001 From: VH Date: Tue, 26 Sep 2023 22:21:50 +0700 Subject: [PATCH 1/4] Centralize disable updating task status checkboxes --- src/components/ReportActionItem/TaskPreview.js | 6 +++++- src/components/ReportActionItem/TaskView.js | 5 ++--- src/components/TaskHeaderActionButton.js | 2 +- src/libs/actions/Task.js | 4 ++++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/ReportActionItem/TaskPreview.js b/src/components/ReportActionItem/TaskPreview.js index 1da348bb067b..d57cd457421a 100644 --- a/src/components/ReportActionItem/TaskPreview.js +++ b/src/components/ReportActionItem/TaskPreview.js @@ -8,6 +8,7 @@ import compose from '../../libs/compose'; import styles from '../../styles/styles'; import ONYXKEYS from '../../ONYXKEYS'; import withLocalize, {withLocalizePropTypes} from '../withLocalize'; +import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes} from '../withCurrentUserPersonalDetails'; import Icon from '../Icon'; import CONST from '../../CONST'; import * as Expensicons from '../Icon/Expensicons'; @@ -51,6 +52,8 @@ const propTypes = { }), ...withLocalizePropTypes, + + ...withCurrentUserPersonalDetailsPropTypes, }; const defaultProps = { @@ -91,7 +94,7 @@ function TaskPreview(props) { style={[styles.mr2]} containerStyle={[styles.taskCheckbox]} isChecked={isTaskCompleted} - disabled={ReportUtils.isCanceledTaskReport(props.taskReport)} + disabled={!Task.canModifyTask(props.taskReport, props.currentUserPersonalDetails.accountID)} onPress={Session.checkIfActionIsAllowed(() => { if (isTaskCompleted) { Task.reopenTask(props.taskReport, taskTitle); @@ -118,6 +121,7 @@ TaskPreview.displayName = 'TaskPreview'; export default compose( withLocalize, + withCurrentUserPersonalDetails, withOnyx({ taskReport: { key: ({taskReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, diff --git a/src/components/ReportActionItem/TaskView.js b/src/components/ReportActionItem/TaskView.js index 39807ab037d5..fd8250fc7876 100644 --- a/src/components/ReportActionItem/TaskView.js +++ b/src/components/ReportActionItem/TaskView.js @@ -49,9 +49,8 @@ function TaskView(props) { const taskTitle = convertToLTR(props.report.reportName || ''); const isCompleted = ReportUtils.isCompletedTaskReport(props.report); const isOpen = ReportUtils.isOpenTaskReport(props.report); - const isCanceled = ReportUtils.isCanceledTaskReport(props.report); const canModifyTask = Task.canModifyTask(props.report, props.currentUserPersonalDetails.accountID); - const disableState = !canModifyTask || isCanceled; + const disableState = !canModifyTask; const isDisableInteractive = !canModifyTask || !isOpen; return ( @@ -102,7 +101,7 @@ function TaskView(props) { containerBorderRadius={8} caretSize={16} accessibilityLabel={taskTitle || props.translate('task.task')} - disabled={isCanceled || !canModifyTask} + disabled={disableState} />