From fa1ebca31e0031fcc7478bef55f797608cfbb4d5 Mon Sep 17 00:00:00 2001 From: someone-here Date: Wed, 20 Sep 2023 15:48:20 +0530 Subject: [PATCH 1/3] Added policyIDto report while creating task --- src/libs/ReportUtils.js | 3 ++- src/libs/actions/Task.js | 4 ++-- src/pages/tasks/NewTaskPage.js | 10 +++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 2475dd40488c..d5c5356f1ed0 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2646,7 +2646,7 @@ function buildOptimisticWorkspaceChats(policyID, policyName) { * @returns {Object} */ -function buildOptimisticTaskReport(ownerAccountID, assigneeAccountID = 0, parentReportID, title, description) { +function buildOptimisticTaskReport(ownerAccountID, assigneeAccountID = 0, parentReportID, title, description, policyID) { return { reportID: generateReportID(), reportName: title, @@ -2656,6 +2656,7 @@ function buildOptimisticTaskReport(ownerAccountID, assigneeAccountID = 0, parent managerID: assigneeAccountID, type: CONST.REPORT.TYPE.TASK, parentReportID, + policyID, stateNum: CONST.REPORT.STATE_NUM.OPEN, statusNum: CONST.REPORT.STATUS.OPEN, }; diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index f1fb4d96f523..6d1c3386c459 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -60,8 +60,8 @@ function clearOutTaskInfo() { * @param {Number} assigneeAccountID * @param {Object} assigneeChatReport - The chat report between you and the assignee */ -function createTaskAndNavigate(parentReportID, title, description, assigneeEmail, assigneeAccountID = 0, assigneeChatReport = null) { - const optimisticTaskReport = ReportUtils.buildOptimisticTaskReport(currentUserAccountID, assigneeAccountID, parentReportID, title, description); +function createTaskAndNavigate(parentReportID, title, description, assigneeEmail, assigneeAccountID = 0, assigneeChatReport = null, policyID = CONST.POLICY.OWNER_ACCOUNT_ID_FAKE) { + const optimisticTaskReport = ReportUtils.buildOptimisticTaskReport(currentUserAccountID, assigneeAccountID, parentReportID, title, description, policyID); const assigneeChatReportID = assigneeChatReport ? assigneeChatReport.reportID : 0; const taskReportID = optimisticTaskReport.reportID; diff --git a/src/pages/tasks/NewTaskPage.js b/src/pages/tasks/NewTaskPage.js index 9fb600e40753..e4aa0bcb08e1 100644 --- a/src/pages/tasks/NewTaskPage.js +++ b/src/pages/tasks/NewTaskPage.js @@ -126,7 +126,15 @@ function NewTaskPage(props) { return; } - Task.createTaskAndNavigate(parentReport.reportID, props.task.title, props.task.description, props.task.assignee, props.task.assigneeAccountID, props.task.assigneeChatReport); + Task.createTaskAndNavigate( + parentReport.reportID, + props.task.title, + props.task.description, + props.task.assignee, + props.task.assigneeAccountID, + props.task.assigneeChatReport, + parentReport.policyID, + ); } if (!Permissions.canUseTasks(props.betas)) { From 305903975abb64b243b7651c57d82665eccce77b Mon Sep 17 00:00:00 2001 From: someone-here Date: Wed, 20 Sep 2023 16:41:23 +0530 Subject: [PATCH 2/3] Fix Lint --- src/libs/ReportUtils.js | 1 + src/libs/actions/Task.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index d5c5356f1ed0..f85b7beefbb4 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2642,6 +2642,7 @@ function buildOptimisticWorkspaceChats(policyID, policyName) { * @param {String} parentReportID - Report ID of the chat where the Task is. * @param {String} title - Task title. * @param {String} description - Task description. + * @param {Number} policyID - Policy ID of the share destination report. * * @returns {Object} */ diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index 6d1c3386c459..5a8cb9917df3 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -59,6 +59,7 @@ function clearOutTaskInfo() { * @param {String} assigneeEmail * @param {Number} assigneeAccountID * @param {Object} assigneeChatReport - The chat report between you and the assignee + * @param {Number} policyID - Policy ID of the share destination report */ function createTaskAndNavigate(parentReportID, title, description, assigneeEmail, assigneeAccountID = 0, assigneeChatReport = null, policyID = CONST.POLICY.OWNER_ACCOUNT_ID_FAKE) { const optimisticTaskReport = ReportUtils.buildOptimisticTaskReport(currentUserAccountID, assigneeAccountID, parentReportID, title, description, policyID); From cf28be0f15c317880734f08c4c020998981cf83e Mon Sep 17 00:00:00 2001 From: someone-here Date: Thu, 21 Sep 2023 15:41:19 +0530 Subject: [PATCH 3/3] Changed default values of policyID --- src/libs/ReportUtils.js | 5 ++--- src/libs/actions/Task.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index d25f77b4b3eb..c27f5f0c4b41 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2646,12 +2646,12 @@ function buildOptimisticWorkspaceChats(policyID, policyName) { * @param {String} parentReportID - Report ID of the chat where the Task is. * @param {String} title - Task title. * @param {String} description - Task description. - * @param {String | undefined} policyID - PolicyID of the parent report + * @param {String} policyID - PolicyID of the parent report * * @returns {Object} */ -function buildOptimisticTaskReport(ownerAccountID, assigneeAccountID = 0, parentReportID, title, description, policyID = undefined) { +function buildOptimisticTaskReport(ownerAccountID, assigneeAccountID = 0, parentReportID, title, description, policyID = CONST.POLICY.OWNER_EMAIL_FAKE) { return { reportID: generateReportID(), reportName: title, @@ -2664,7 +2664,6 @@ function buildOptimisticTaskReport(ownerAccountID, assigneeAccountID = 0, parent policyID, stateNum: CONST.REPORT.STATE_NUM.OPEN, statusNum: CONST.REPORT.STATUS.OPEN, - ...(_.isUndefined(policyID) ? {} : {policyID}), }; } diff --git a/src/libs/actions/Task.js b/src/libs/actions/Task.js index 4e71a8793f1e..fa6cdcc77706 100644 --- a/src/libs/actions/Task.js +++ b/src/libs/actions/Task.js @@ -59,9 +59,9 @@ function clearOutTaskInfo() { * @param {String} assigneeEmail * @param {Number} assigneeAccountID * @param {Object} assigneeChatReport - The chat report between you and the assignee - * @param {String | undefined} policyID - the policyID of the parent report + * @param {String} policyID - the policyID of the parent report */ -function createTaskAndNavigate(parentReportID, title, description, assigneeEmail, assigneeAccountID = 0, assigneeChatReport = null, policyID = undefined) { +function createTaskAndNavigate(parentReportID, title, description, assigneeEmail, assigneeAccountID = 0, assigneeChatReport = null, policyID = CONST.POLICY.OWNER_EMAIL_FAKE) { const optimisticTaskReport = ReportUtils.buildOptimisticTaskReport(currentUserAccountID, assigneeAccountID, parentReportID, title, description, policyID); const assigneeChatReportID = assigneeChatReport ? assigneeChatReport.reportID : 0;