-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Migrate tasks to use childManagerAccountID
#21781
Changes from 9 commits
0b00788
36d2536
a7381f4
74f4a7a
778891a
c8f63aa
e6c0e7f
7583e4f
a1ef3e5
a76e4a5
87ca096
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ import React from 'react'; | |
import {View} from 'react-native'; | ||
import PropTypes from 'prop-types'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import lodashGet from 'lodash/get'; | ||
import compose from '../../libs/compose'; | ||
import styles from '../../styles/styles'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
|
@@ -18,8 +19,12 @@ import reportActionPropTypes from '../../pages/home/report/reportActionPropTypes | |
import * as TaskUtils from '../../libs/actions/Task'; | ||
import RenderHTML from '../RenderHTML'; | ||
import PressableWithoutFeedback from '../Pressable/PressableWithoutFeedback'; | ||
import personalDetailsPropType from '../../pages/personalDetailsPropType'; | ||
|
||
const propTypes = { | ||
/** All personal details asssociated with user */ | ||
personalDetailsList: personalDetailsPropType, | ||
|
||
/** The ID of the associated taskReport */ | ||
taskReportID: PropTypes.string.isRequired, | ||
|
||
|
@@ -46,6 +51,7 @@ const propTypes = { | |
}; | ||
|
||
const defaultProps = { | ||
personalDetailsList: {}, | ||
taskReport: {}, | ||
isHovered: false, | ||
}; | ||
|
@@ -58,7 +64,8 @@ function TaskPreview(props) { | |
? 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 taskAssigneeAccountID = TaskUtils.getTaskAssigneeAccountID(props.taskReport); | ||
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. We didn't consider the case where the 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. hmm if task report could be empty, would this have crashed before too? 🤔 (since we used to directly access |
||
const taskAssignee = lodashGet(props.personalDetailsList, [taskAssigneeAccountID, 'login'], ''); | ||
const htmlForTaskPreview = taskAssignee ? `<comment><mention-user>@${taskAssignee}</mention-user> ${taskTitle}</comment>` : `<comment>${taskTitle}</comment>`; | ||
|
||
return ( | ||
|
@@ -103,5 +110,8 @@ export default compose( | |
taskReport: { | ||
key: ({taskReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`, | ||
}, | ||
personalDetailsList: { | ||
key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
}, | ||
}), | ||
)(TaskPreview); |
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. Noticed this needed to be updated, maybe it belongs in a different PR? 🤷 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. What's this file change for? I don't see any lint issue in latest main 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. You can see I'm just including extra prop types / default prop types that were missing. We used |
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.
props.action
already haschildManagerAccountID
. Is there any problem using it directly?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.
I don't think so - but since we were defaulting to
managerEmail
first, I thought it would be best if we default tomanagerID
first as well, THEN usechildManagerAccountID
- and that logic exists in this function so I thought it would be better to reuse it, do you disagree?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.
ok agree. But as I reported, we should fallback to original logic if report.managerID or action.childManagerAccountID doesn't exist.
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.
"original logic" being
props.taskReport.managerEmail || props.action.childManagerEmail;
? We're trying to get rid of those :D