Skip to content

Commit

Permalink
Merge pull request #31900 from bernhardoj/fix/28187-workspace-report-…
Browse files Browse the repository at this point in the history
…acrhive

Fix workspace money request is archived when we delete the workspace
  • Loading branch information
MariaHCD authored Jan 24, 2024
2 parents a8a3a4c + 4c66022 commit f8ac17b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/pages/workspace/WorkspaceInitialPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ function dismissError(policyID) {
Policy.removeWorkspace(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);
}

function WorkspaceInitialPage(props) {
const styles = useThemeStyles();
const policy = props.policyDraft && props.policyDraft.id ? props.policyDraft : props.policy;
Expand Down Expand Up @@ -111,7 +120,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, shouldArchiveReport), policy.name);
setIsDeleteModalOpen(false);
// Pop the deleted workspace page before opening workspace settings.
Navigation.goBack(ROUTES.SETTINGS_WORKSPACES);
Expand Down

0 comments on commit f8ac17b

Please sign in to comment.