Skip to content

Commit

Permalink
Merge pull request #21781 from Expensify/beaman-migrateToChildManager…
Browse files Browse the repository at this point in the history
…AccountID

Migrate tasks to use `childManagerAccountID`
  • Loading branch information
puneetlath authored Jul 6, 2023
2 parents 411d466 + 87ca096 commit 34b792a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 11 additions & 1 deletion src/components/ReportActionItem/TaskPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 _ from 'underscore';
import compose from '../../libs/compose';
import styles from '../../styles/styles';
Expand All @@ -19,8 +20,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,

Expand All @@ -47,6 +52,7 @@ const propTypes = {
};

const defaultProps = {
personalDetailsList: {},
taskReport: {},
isHovered: false,
};
Expand All @@ -59,7 +65,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);
const taskAssignee = lodashGet(props.personalDetailsList, [taskAssigneeAccountID, 'login'], lodashGet(props.personalDetailsList, [taskAssigneeAccountID, 'displayName'], ''));
const htmlForTaskPreview = taskAssignee ? `<comment><mention-user>@${taskAssignee}</mention-user> ${taskTitle}</comment>` : `<comment>${taskTitle}</comment>`;

return (
Expand Down Expand Up @@ -106,5 +113,8 @@ export default compose(
taskReport: {
key: ({taskReportID}) => `${ONYXKEYS.COLLECTION.REPORT}${taskReportID}`,
},
personalDetailsList: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
}),
)(TaskPreview);
1 change: 0 additions & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,6 @@ function buildOptimisticTaskCommentReportAction(taskReportID, taskTitle, taskAss
reportAction.reportAction.parentReportID = parentReportID;
reportAction.reportAction.childType = CONST.REPORT.TYPE.TASK;
reportAction.reportAction.childReportName = taskTitle;
reportAction.reportAction.childManagerEmail = taskAssignee;
reportAction.reportAction.childManagerAccountID = taskAssigneeAccountID;
reportAction.reportAction.childStatusNum = CONST.REPORT.STATUS.OPEN;
reportAction.reportAction.childStateNum = CONST.REPORT.STATE_NUM.OPEN;
Expand Down
9 changes: 1 addition & 8 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import ROUTES from '../../ROUTES';
import CONST from '../../CONST';
import DateUtils from '../DateUtils';
import * as UserUtils from '../UserUtils';
import * as PersonalDetailsUtils from '../PersonalDetailsUtils';
import * as ReportActionsUtils from '../ReportActionsUtils';

let currentUserEmail;
Expand Down Expand Up @@ -656,13 +655,7 @@ function getTaskAssigneeAccountID(taskReport) {
}

const reportAction = ReportActionsUtils.getParentReportAction(taskReport);
const childManagerEmail = lodashGet(reportAction, 'childManagerEmail', '');

if (!childManagerEmail) {
return null;
}

return PersonalDetailsUtils.getAccountIDsByLogins([childManagerEmail])[0];
return lodashGet(reportAction, 'childManagerAccountID');
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/pages/workspace/WorkspaceMembersPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ import * as UserUtils from '../../libs/UserUtils';
import FormHelpMessage from '../../components/FormHelpMessage';
import TextInput from '../../components/TextInput';
import KeyboardDismissingFlatList from '../../components/KeyboardDismissingFlatList';
import withCurrentUserPersonalDetails from '../../components/withCurrentUserPersonalDetails';
import withCurrentUserPersonalDetails, {withCurrentUserPersonalDetailsPropTypes, withCurrentUserPersonalDetailsDefaultProps} from '../../components/withCurrentUserPersonalDetails';
import * as PolicyUtils from '../../libs/PolicyUtils';
import PressableWithFeedback from '../../components/Pressable/PressableWithFeedback';
import usePrevious from '../../hooks/usePrevious';
import Log from '../../libs/Log';
import * as PersonalDetailsUtils from '../../libs/PersonalDetailsUtils';

const propTypes = {
/** The personal details of the person who is logged in */
/** All personal details asssociated with user */
personalDetails: personalDetailsPropType,

/** URL Route params */
Expand All @@ -61,6 +61,7 @@ const propTypes = {
...policyPropTypes,
...withLocalizePropTypes,
...windowDimensionsPropTypes,
...withCurrentUserPersonalDetailsPropTypes,
network: networkPropTypes.isRequired,
};

Expand All @@ -70,6 +71,7 @@ const defaultProps = {
accountID: 0,
},
...policyDefaultProps,
...withCurrentUserPersonalDetailsDefaultProps,
};

function WorkspaceMembersPage(props) {
Expand Down

0 comments on commit 34b792a

Please sign in to comment.