Skip to content

Commit

Permalink
Merge pull request #20544 from dukenv0307/fix/regression-19089
Browse files Browse the repository at this point in the history
  • Loading branch information
thienlnam authored Jun 12, 2023
2 parents 559924e + a1726d5 commit 99e184c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Onyx from 'react-native-onyx';
import lodashGet from 'lodash/get';
import Str from 'expensify-common/lib/str';
import _ from 'underscore';
import ONYXKEYS from '../../ONYXKEYS';
import * as API from '../API';
import * as ReportUtils from '../ReportUtils';
Expand Down Expand Up @@ -278,19 +279,18 @@ function reopenTask(taskReportID, taskTitle) {
* @function editTask
* @param {object} report
* @param {string} ownerEmail
* @param {string} title
* @param {string} description
* @param {string} assignee
* @param {{title?: string, description?: string, assignee?:string}} editedTask
* @returns {object} action
*
*/

function editTaskAndNavigate(report, ownerEmail, title, description, assignee) {
function editTaskAndNavigate(report, ownerEmail, {title, description, assignee}) {
// Create the EditedReportAction on the task
const editTaskReportAction = ReportUtils.buildOptimisticEditedTaskReportAction(ownerEmail);

// Sometimes title is undefined, so we need to check for that, and we provide it to multiple functions
// Sometimes title or description is undefined, so we need to check for that, and we provide it to multiple functions
const reportName = (title || report.reportName).trim();
const reportDescription = (!_.isUndefined(description) ? description : report.description).trim();

// If we make a change to the assignee, we want to add a comment to the assignee's chat
let optimisticAssigneeAddComment;
Expand All @@ -313,7 +313,7 @@ function editTaskAndNavigate(report, ownerEmail, title, description, assignee) {
key: `${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`,
value: {
reportName,
description: description.trim(),
description: reportDescription,
managerEmail: assignee || report.managerEmail,
},
},
Expand Down Expand Up @@ -368,7 +368,7 @@ function editTaskAndNavigate(report, ownerEmail, title, description, assignee) {
{
taskReportID: report.reportID,
title: reportName,
description: (description || report.description).trim(),
description: reportDescription,
assignee: assignee || report.managerEmail,
editedTaskReportActionID: editTaskReportAction.reportActionID,
assigneeChatReportActionID: optimisticAssigneeAddComment ? optimisticAssigneeAddComment.reportAction.reportActionID : 0,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tasks/TaskAssigneeSelectorModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const TaskAssigneeSelectorModal = (props) => {
// This would cause the app to crash, so we need to make sure we have a DM thread
TaskUtils.setAssigneeValue(option.login, props.task.shareDestination, OptionsListUtils.isCurrentUser(option));
// Pass through the selected assignee
TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, '', '', option.login);
TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, {assignee: option.login});
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/tasks/TaskDescriptionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function TaskDescriptionPage(props) {
(values) => {
// Set the description of the report in the store and then call TaskUtils.editTaskReport
// to update the description of the report on the server
TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, '', values.description, '');
TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, {description: values.description});
},
[props],
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/tasks/TaskTitlePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function TaskTitlePage(props) {
// Set the description of the report in the store and then call TaskUtils.editTaskReport
// to update the description of the report on the server

TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, values.title, '', '');
TaskUtils.editTaskAndNavigate(props.task.report, props.session.email, {title: values.title});
},
[props],
);
Expand Down

0 comments on commit 99e184c

Please sign in to comment.