Skip to content

Commit

Permalink
Merge pull request #23530 from dukenv0307/new-bug-on-asisgnee-page
Browse files Browse the repository at this point in the history
Fix: cannot change assignee after task created
  • Loading branch information
pecanoro authored Aug 8, 2023
2 parents dab2905 + a1e39d1 commit b812cfe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ function editTaskAndNavigate(report, ownerAccountID, {title, description, assign
let optimisticAssigneeAddComment;
let assigneeChatReportID;
if (assigneeAccountID && assigneeAccountID !== report.managerID && assigneeAccountID !== ownerAccountID) {
assigneeChatReportID = ReportUtils.getChatByParticipants([assigneeAccountID]).reportID;
assigneeChatReportID = lodashGet(ReportUtils.getChatByParticipants([assigneeAccountID]), ['reportID'], undefined);

if (assigneeChatReportID !== report.parentReportID.toString()) {
if (assigneeChatReportID && assigneeChatReportID !== report.parentReportID.toString()) {
optimisticAssigneeAddComment = ReportUtils.buildOptimisticTaskCommentReportAction(
report.reportID,
reportName,
Expand Down
15 changes: 11 additions & 4 deletions src/pages/tasks/TaskAssigneeSelectorModal.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable es/no-optional-chaining */
import React, {useState, useEffect, useMemo, useCallback} from 'react';
import {View} from 'react-native';
import lodashGet from 'lodash/get';
import _ from 'underscore';
import PropTypes from 'prop-types';
import {withOnyx} from 'react-native-onyx';
import lodashGet from 'lodash/get';
import OptionsSelector from '../../components/OptionsSelector';
import * as OptionsListUtils from '../../libs/OptionsListUtils';
import ONYXKEYS from '../../ONYXKEYS';
Expand Down Expand Up @@ -108,6 +108,13 @@ function TaskAssigneeSelectorModal(props) {
setSearchValue(newSearchTerm);
};

const report = useMemo(() => {
if (!props.route.params || !props.route.params.reportID) {
return null;
}
return props.reports[`${ONYXKEYS.COLLECTION.REPORT}${props.route.params.reportID}`];
}, [props.reports, props.route.params]);

const sections = useMemo(() => {
const sectionsList = [];
let indexOffset = 0;
Expand Down Expand Up @@ -164,13 +171,13 @@ function TaskAssigneeSelectorModal(props) {
}

// Check to see if we're editing a task and if so, update the assignee
if (props.route.params.reportID && props.task.report.reportID === props.route.params.reportID) {
if (report) {
// There was an issue where sometimes a new assignee didn't have a DM thread
// This would cause the app to crash, so we need to make sure we have a DM thread
Task.setAssigneeValue(option.login, option.accountID, props.task.shareDestination, OptionsListUtils.isCurrentUser(option));
Task.setAssigneeValue(option.login, option.accountID, props.route.params.reportID, OptionsListUtils.isCurrentUser(option));

// Pass through the selected assignee
Task.editTaskAndNavigate(props.task.report, props.session.accountID, {
Task.editTaskAndNavigate(report, props.session.accountID, {
assignee: option.login,
assigneeAccountID: option.accountID,
});
Expand Down

0 comments on commit b812cfe

Please sign in to comment.