Skip to content
Merged
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
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);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Task report is also added considering we want to archive task report too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the condition inverted?
What are the remaining reports other than money request reports, chat room, policy expense chat, task report?
Does this also archive #announce, #admins rooms and threads?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition is based on this comment

Does this also archive #announce, #admins rooms and threads?

Both are chat rooms, thread will take the parent chat type


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