-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix empty assignee in TaskHeader and update permission to mark Task complete/incomplete/cancel in Task report #20689
Changes from all commits
859b7b0
1372cae
0a7cb1e
6449379
97e55fc
1ee30aa
0fc044c
53ed4a3
a916971
14d1b94
a48c850
88ad19b
9510cff
7d468e4
f4ca4c8
206d364
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,11 @@ const propTypes = { | |
guideCalendarLink: PropTypes.string, | ||
}), | ||
|
||
/** Current user session */ | ||
session: PropTypes.shape({ | ||
accountID: PropTypes.number, | ||
}), | ||
|
||
/** The report actions from the parent report */ | ||
// TO DO: Replace with HOC https://github.com/Expensify/App/issues/18769. | ||
// eslint-disable-next-line react/no-unused-prop-types | ||
|
@@ -68,6 +73,9 @@ const defaultProps = { | |
guideCalendarLink: null, | ||
}, | ||
parentReport: {}, | ||
session: { | ||
accountID: 0, | ||
}, | ||
}; | ||
|
||
function HeaderView(props) { | ||
|
@@ -91,7 +99,8 @@ function HeaderView(props) { | |
const shouldShowCallButton = (isConcierge && guideCalendarLink) || (!isAutomatedExpensifyAccount && !isTaskReport); | ||
const threeDotMenuItems = []; | ||
if (isTaskReport) { | ||
if (props.report.stateNum === CONST.REPORT.STATE_NUM.OPEN && props.report.statusNum === CONST.REPORT.STATUS.OPEN) { | ||
const isTaskAssigneeOrTaskOwner = Task.isTaskAssigneeOrTaskOwner(props.report, props.session.accountID); | ||
if (props.report.stateNum === CONST.REPORT.STATE_NUM.OPEN && props.report.statusNum === CONST.REPORT.STATUS.OPEN && isTaskAssigneeOrTaskOwner) { | ||
threeDotMenuItems.push({ | ||
icon: Expensicons.Checkmark, | ||
text: props.translate('newTaskPage.markAsDone'), | ||
|
@@ -100,7 +109,7 @@ function HeaderView(props) { | |
} | ||
|
||
// Task is marked as completed | ||
if (props.report.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum === CONST.REPORT.STATUS.APPROVED) { | ||
if (props.report.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum === CONST.REPORT.STATUS.APPROVED && isTaskAssigneeOrTaskOwner) { | ||
threeDotMenuItems.push({ | ||
icon: Expensicons.Checkmark, | ||
text: props.translate('newTaskPage.markAsIncomplete'), | ||
|
@@ -109,7 +118,7 @@ function HeaderView(props) { | |
} | ||
|
||
// Task is not closed | ||
if (props.report.stateNum !== CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum !== CONST.REPORT.STATUS.CLOSED) { | ||
if (props.report.stateNum !== CONST.REPORT.STATE_NUM.SUBMITTED && props.report.statusNum !== CONST.REPORT.STATUS.CLOSED && isTaskAssigneeOrTaskOwner) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this one. Should we allow assignee to cancel the task? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so. If this is a flow we do not want in the future we can create another issue for it. But I believe an assignee should be able to cancel a task. |
||
threeDotMenuItems.push({ | ||
icon: Expensicons.Trashcan, | ||
text: props.translate('common.cancel'), | ||
|
@@ -258,5 +267,8 @@ export default compose( | |
parentReport: { | ||
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID || report.reportID}`, | ||
}, | ||
session: { | ||
key: ONYXKEYS.SESSION, | ||
}, | ||
}), | ||
)(HeaderView); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming from #22398:
I understand this logic already existed but we should avoid this pattern and it's already in checklist.
This could have been fixed earlier while merging main.