Skip to content

Commit

Permalink
Merge pull request #28128 from esh-g/task-action-assignee
Browse files Browse the repository at this point in the history
  • Loading branch information
thienlnam authored Oct 2, 2023
2 parents 1341ea2 + d78e12c commit 96f93fe
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 69 deletions.
12 changes: 0 additions & 12 deletions src/libs/ReportActionsUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,6 @@ function getParentReportAction(report, allReportActionsParam = undefined) {
return lodashGet(allReportActionsParam || allReportActions, [report.parentReportID, report.parentReportActionID], {});
}

/**
* Find the reportAction having the given childReportID in parent report actions
*
* @param {String} childReportID
* @param {String} parentReportID
* @returns {Object}
*/
function getParentReportActionInReport(childReportID, parentReportID) {
return _.find(allReportActions[parentReportID], (reportAction) => reportAction && `${reportAction.childReportID}` === `${childReportID}`);
}

/**
* Determines if the given report action is sent money report action by checking for 'pay' type and presence of IOUDetails object.
*
Expand Down Expand Up @@ -679,7 +668,6 @@ export {
getReportPreviewAction,
isCreatedTaskReportAction,
getParentReportAction,
getParentReportActionInReport,
isTransactionThread,
isSentMoneyReportAction,
isDeletedParentAction,
Expand Down
25 changes: 0 additions & 25 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3385,30 +3385,6 @@ function isReportDataReady() {
return !_.isEmpty(allReports) && _.some(_.keys(allReports), (key) => allReports[key].reportID);
}

/**
* Find the parent report action in assignee report for a task report
* Returns an empty object if assignee report is the same as the share destination report
*
* @param {Object} taskReport
* @returns {Object}
*/
function getTaskParentReportActionIDInAssigneeReport(taskReport) {
const assigneeChatReportID = lodashGet(getChatByParticipants(isReportManager(taskReport) ? [taskReport.ownerAccountID] : [taskReport.managerID]), 'reportID');
if (!assigneeChatReportID || assigneeChatReportID === taskReport.parentReportID) {
return {};
}

const clonedParentReportActionID = lodashGet(ReportActionsUtils.getParentReportActionInReport(taskReport.reportID, assigneeChatReportID), 'reportActionID');
if (!clonedParentReportActionID) {
return {};
}

return {
reportID: assigneeChatReportID,
reportActionID: clonedParentReportActionID,
};
}

/**
* Return the errors we have when creating a chat or a workspace room
* @param {Object} report
Expand Down Expand Up @@ -3793,7 +3769,6 @@ export {
getBankAccountRoute,
getParentReport,
getRootParentReport,
getTaskParentReportActionIDInAssigneeReport,
getReportPreviewMessage,
getModifiedExpenseMessage,
shouldDisableWriteActions,
Expand Down
32 changes: 0 additions & 32 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,22 +273,6 @@ function completeTask(taskReport) {
},
];

// Multiple report actions can link to the same child. Both share destination (task parent) and assignee report link to the same report action.
// We need to find and update the other parent report action (in assignee report). More info https://github.com/Expensify/App/issues/23920#issuecomment-1663092717
const assigneeReportAction = ReportUtils.getTaskParentReportActionIDInAssigneeReport(taskReport);
if (!_.isEmpty(assigneeReportAction)) {
const optimisticDataForClonedParentReportAction = ReportUtils.getOptimisticDataForParentReportAction(
taskReportID,
completedTaskReportAction.created,
CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
assigneeReportAction.reportID,
assigneeReportAction.reportActionID,
);
if (!_.isEmpty(optimisticDataForClonedParentReportAction)) {
optimisticData.push(optimisticDataForClonedParentReportAction);
}
}

API.write(
'CompleteTask',
{
Expand Down Expand Up @@ -359,22 +343,6 @@ function reopenTask(taskReport) {
},
];

// Multiple report actions can link to the same child. Both share destination (task parent) and assignee report link to the same report action.
// We need to find and update the other parent report action (in assignee report). More info https://github.com/Expensify/App/issues/23920#issuecomment-1663092717
const assigneeReportAction = ReportUtils.getTaskParentReportActionIDInAssigneeReport(taskReport);
if (!_.isEmpty(assigneeReportAction)) {
const optimisticDataForClonedParentReportAction = ReportUtils.getOptimisticDataForParentReportAction(
taskReportID,
reopenedTaskReportAction.created,
CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD,
assigneeReportAction.reportID,
assigneeReportAction.reportActionID,
);
if (!_.isEmpty(optimisticDataForClonedParentReportAction)) {
optimisticData.push(optimisticDataForClonedParentReportAction);
}
}

API.write(
'ReopenTask',
{
Expand Down

0 comments on commit 96f93fe

Please sign in to comment.