Skip to content

Commit

Permalink
Merge pull request Expensify#31527 from dukenv0307/fix/31446
Browse files Browse the repository at this point in the history
Disable complete task for anonymous user
  • Loading branch information
tylerkaraszewski authored Nov 21, 2023
2 parents 360fe05 + 18be80e commit da549c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/TaskHeaderActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import compose from '@libs/compose';
import * as ReportUtils from '@libs/ReportUtils';
import reportPropTypes from '@pages/reportPropTypes';
import useThemeStyles from '@styles/useThemeStyles';
import * as Session from '@userActions/Session';
import * as Task from '@userActions/Task';
import ONYXKEYS from '@src/ONYXKEYS';
import Button from './Button';
Expand Down Expand Up @@ -38,7 +39,7 @@ function TaskHeaderActionButton(props) {
isDisabled={!Task.canModifyTask(props.report, props.session.accountID)}
medium
text={props.translate(ReportUtils.isCompletedTaskReport(props.report) ? 'task.markAsIncomplete' : 'task.markAsComplete')}
onPress={() => (ReportUtils.isCompletedTaskReport(props.report) ? Task.reopenTask(props.report) : Task.completeTask(props.report))}
onPress={Session.checkIfActionIsAllowed(() => (ReportUtils.isCompletedTaskReport(props.report) ? Task.reopenTask(props.report) : Task.completeTask(props.report)))}
style={[styles.flex1]}
/>
</View>
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/ReportActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function clearReportActionErrors(reportID: string, reportAction: ReportAction) {

// Delete the failed task report too
const taskReportID = reportAction.message?.[0]?.taskReportID;
if (taskReportID) {
if (taskReportID && ReportActionUtils.isCreatedTaskReportAction(reportAction)) {
Report.deleteReport(taskReportID);
}
return;
Expand Down

0 comments on commit da549c0

Please sign in to comment.