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

Fix user cannot remove the description #20544

Merged
merged 6 commits into from
Jun 12, 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
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