From de66326d622a902ec6c3519b70941bf082139bf8 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 27 Nov 2023 16:44:30 +0800 Subject: [PATCH 1/4] only archive chat room, expense chat, and task --- src/pages/workspace/WorkspaceInitialPage.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index 77e831e62b63..fa29cf3ded22 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -67,6 +67,14 @@ function dismissError(policyID) { Policy.removeWorkspace(policyID); } +/** + * Whether the policy report should be deleted when we delete the policy. + * @param {Object} report + */ +function shouldDeleteReport(report) { + return ReportUtils.isChatRoom(report) || ReportUtils.isPolicyExpenseChat(report) || ReportUtils.isTaskReport(report); +} + function WorkspaceInitialPage(props) { const styles = useThemeStyles(); const policy = props.policyDraft && props.policyDraft.id ? props.policyDraft : props.policy; @@ -111,7 +119,7 @@ function WorkspaceInitialPage(props) { * Call the delete policy and hide the modal */ const confirmDeleteAndHideModal = useCallback(() => { - Policy.deleteWorkspace(policyID, policyReports, policy.name); + Policy.deleteWorkspace(policyID, _.filter(policyReports, shouldDeleteReport), policy.name); setIsDeleteModalOpen(false); // Pop the deleted workspace page before opening workspace settings. Navigation.goBack(ROUTES.SETTINGS_WORKSPACES); From 79aaa4b766e5ad8402f11dbadc22acf3c5b0b6aa Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 27 Nov 2023 16:53:42 +0800 Subject: [PATCH 2/4] update func name and comment --- src/pages/workspace/WorkspaceInitialPage.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index fa29cf3ded22..76e8d30093cc 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -68,10 +68,10 @@ function dismissError(policyID) { } /** - * Whether the policy report should be deleted when we delete the policy. + * Whether the policy report should be archived when we delete the policy. * @param {Object} report */ -function shouldDeleteReport(report) { +function shouldArchiveReport(report) { return ReportUtils.isChatRoom(report) || ReportUtils.isPolicyExpenseChat(report) || ReportUtils.isTaskReport(report); } @@ -119,7 +119,7 @@ function WorkspaceInitialPage(props) { * Call the delete policy and hide the modal */ const confirmDeleteAndHideModal = useCallback(() => { - Policy.deleteWorkspace(policyID, _.filter(policyReports, shouldDeleteReport), policy.name); + Policy.deleteWorkspace(policyID, _.filter(policyReports, shouldArchiveReport), policy.name); setIsDeleteModalOpen(false); // Pop the deleted workspace page before opening workspace settings. Navigation.goBack(ROUTES.SETTINGS_WORKSPACES); From 86fa1820c0b6b16d55a9f259b573682a0a7e776d Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 27 Nov 2023 16:56:11 +0800 Subject: [PATCH 3/4] add jsdoc returns --- src/pages/workspace/WorkspaceInitialPage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index 76e8d30093cc..c899fffff4e2 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -70,6 +70,7 @@ function dismissError(policyID) { /** * Whether the policy report should be archived when we delete the policy. * @param {Object} report + * @returns {Boolean} */ function shouldArchiveReport(report) { return ReportUtils.isChatRoom(report) || ReportUtils.isPolicyExpenseChat(report) || ReportUtils.isTaskReport(report); From 2346a024ded1c593ee6df83276f88c11d1a3243a Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Mon, 27 Nov 2023 17:00:07 +0800 Subject: [PATCH 4/4] prettier --- src/pages/workspace/WorkspaceInitialPage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index c899fffff4e2..66d9f2f7f518 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -69,7 +69,7 @@ function dismissError(policyID) { /** * Whether the policy report should be archived when we delete the policy. - * @param {Object} report + * @param {Object} report * @returns {Boolean} */ function shouldArchiveReport(report) {