Skip to content
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

Don't add optimistic replies to task assignee report #28128

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -674,7 +663,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 @@ -3355,30 +3355,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 @@ -3723,7 +3699,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 @@ -274,22 +274,6 @@ function completeTask(taskReport, taskTitle) {
},
];

// 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);
}
}

esh-g marked this conversation as resolved.
Show resolved Hide resolved
API.write(
'CompleteTask',
{
Expand Down Expand Up @@ -361,22 +345,6 @@ function reopenTask(taskReport, taskTitle) {
},
];

// 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);
}
}

esh-g marked this conversation as resolved.
Show resolved Hide resolved
API.write(
'ReopenTask',
{
Expand Down