Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Srikar test remove optimistic delete policy #57990

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
44 changes: 22 additions & 22 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
PolicyCategory,
ReimbursementAccount,
Report,
ReportAction,

Check failure on line 94 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / ESLint check

'ReportAction' is defined but never used

Check failure on line 94 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'ReportAction' is defined but never used
ReportActions,
Request,
TaxRatesWithDefault,
Expand Down Expand Up @@ -303,7 +303,7 @@
/**
* Delete the workspace
*/
function deleteWorkspace(policyID: string, policyName: string) {

Check failure on line 306 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / ESLint check

'policyName' is defined but never used

Check failure on line 306 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'policyName' is defined but never used
if (!allPolicies) {
return;
}
Expand Down Expand Up @@ -336,7 +336,7 @@
(report) => ReportUtils.isPolicyRelatedReport(report, policyID) && (ReportUtils.isChatRoom(report) || ReportUtils.isPolicyExpenseChat(report) || ReportUtils.isTaskReport(report)),
);
const finallyData: OnyxUpdate[] = [];
const currentTime = DateUtils.getDBTime();

Check failure on line 339 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / ESLint check

'currentTime' is assigned a value but never used

Check failure on line 339 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'currentTime' is assigned a value but never used
reportsToArchive.forEach((report) => {
const {reportID, ownerAccountID} = report ?? {};
const isInvoiceReceiverReport = report?.invoiceReceiver && 'policyID' in report.invoiceReceiver && report.invoiceReceiver.policyID === policyID;
Expand All @@ -352,13 +352,13 @@
},
});

optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`,
value: {
private_isArchived: currentTime,
},
});
// optimisticData.push({
// onyxMethod: Onyx.METHOD.MERGE,
// key: `${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`,
// value: {
// private_isArchived: currentTime,
// },
// });

optimisticData.push({
onyxMethod: Onyx.METHOD.SET,
Expand All @@ -370,26 +370,26 @@
// Announce & admin chats have FAKE owners, but workspace chats w/ users do have owners.
let emailClosingReport: string = CONST.POLICY.OWNER_EMAIL_FAKE;
if (!!ownerAccountID && ownerAccountID !== CONST.POLICY.OWNER_ACCOUNT_ID_FAKE) {
emailClosingReport = allPersonalDetails?.[ownerAccountID]?.login ?? '';

Check failure on line 373 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / ESLint check

'emailClosingReport' is assigned a value but never used

Check failure on line 373 in src/libs/actions/Policy/Policy.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'emailClosingReport' is assigned a value but never used
}
const optimisticClosedReportAction = ReportUtils.buildOptimisticClosedReportAction(emailClosingReport, policyName, CONST.REPORT.ARCHIVE_REASON.POLICY_DELETED);
optimisticData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
value: {
[optimisticClosedReportAction.reportActionID]: optimisticClosedReportAction as ReportAction,
},
});
// const optimisticClosedReportAction = ReportUtils.buildOptimisticClosedReportAction(emailClosingReport, policyName, CONST.REPORT.ARCHIVE_REASON.POLICY_DELETED);
// optimisticData.push({
// onyxMethod: Onyx.METHOD.MERGE,
// key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
// value: {
// [optimisticClosedReportAction.reportActionID]: optimisticClosedReportAction as ReportAction,
// },
// });

// We are temporarily adding this workaround because 'DeleteWorkspace' doesn't
// support receiving the optimistic reportActions' ids for the moment.
finallyData.push({
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
value: {
[optimisticClosedReportAction.reportActionID]: null,
},
});
// finallyData.push({
// onyxMethod: Onyx.METHOD.MERGE,
// key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
// value: {
// [optimisticClosedReportAction.reportActionID]: null,
// },
// });
});

const policy = getPolicy(policyID);
Expand Down
Loading