From 661da7efde8227fe2683042aeac490423c9c2b34 Mon Sep 17 00:00:00 2001 From: Rory Abraham <47436092+roryabraham@users.noreply.github.com> Date: Mon, 15 Jan 2024 11:48:44 -0800 Subject: [PATCH] Merge pull request #34527 from mkhutornyi/fix-34518 fix unable to add assignee when creating a task (cherry picked from commit 34ec480c961d97c2f1e35ac0f55f83fb9abb8130) --- src/pages/tasks/TaskAssigneeSelectorModal.js | 42 ++++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/pages/tasks/TaskAssigneeSelectorModal.js b/src/pages/tasks/TaskAssigneeSelectorModal.js index a4fc61910be2..1a526a9cdd9b 100644 --- a/src/pages/tasks/TaskAssigneeSelectorModal.js +++ b/src/pages/tasks/TaskAssigneeSelectorModal.js @@ -184,29 +184,29 @@ function TaskAssigneeSelectorModal(props) { return sectionsList; }, [filteredCurrentUserOption, filteredPersonalDetails, filteredRecentReports, filteredUserToInvite, props]); - const selectReport = (option) => { - if (!option) { - return; - } - - // Check to see if we're creating a new task - // If there's no route params, we're creating a new task - if (!props.route.params && option.accountID) { - Task.setAssigneeValue(option.login, option.accountID, props.task.shareDestination, OptionsListUtils.isCurrentUser(option)); - return Navigation.goBack(ROUTES.NEW_TASK); - } - - // Check to see if we're editing a task and if so, update the assignee - if (report) { - if (option.accountID !== report.managerID) { - const assigneeChatReport = Task.setAssigneeValue(option.login, option.accountID, props.route.params.reportID, OptionsListUtils.isCurrentUser(option)); + const selectReport = useCallback( + (option) => { + if (!option) { + return; + } - // Pass through the selected assignee - Task.editTaskAssignee(report, props.session.accountID, option.login, option.accountID, assigneeChatReport); + // Check to see if we're editing a task and if so, update the assignee + if (report) { + if (option.accountID !== report.managerID) { + const assigneeChatReport = Task.setAssigneeValue(option.login, option.accountID, report.reportID, OptionsListUtils.isCurrentUser(option)); + + // Pass through the selected assignee + Task.editTaskAssignee(report, props.session.accountID, option.login, option.accountID, assigneeChatReport); + } + Navigation.dismissModal(report.reportID); + // If there's no report, we're creating a new task + } else if (option.accountID) { + Task.setAssigneeValue(option.login, option.accountID, props.task.shareDestination, OptionsListUtils.isCurrentUser(option)); + Navigation.goBack(ROUTES.NEW_TASK); } - return Navigation.dismissModal(report.reportID); - } - }; + }, + [props.session.accountID, props.task.shareDestination, report], + ); const isOpen = ReportUtils.isOpenTaskReport(report); const canModifyTask = Task.canModifyTask(report, props.currentUserPersonalDetails.accountID, lodashGet(props.rootParentReportPolicy, 'role', ''));