Skip to content
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
4 changes: 2 additions & 2 deletions src/libs/actions/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,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