-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix: un-report the transactions on the report (move to selfDM) when delete #82619
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
Changes from all commits
b323767
414c755
c7e83e6
5a81ec6
bd19218
4a19f61
bde6686
36d87d1
656a935
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -804,11 +804,21 @@ function bulkDeleteReports( | |
| const transactionIDList: string[] = []; | ||
| const reportIDList: string[] = []; | ||
|
|
||
| // Collect all report IDs that are being deleted | ||
| for (const key of Object.keys(selectedTransactions)) { | ||
| const selectedItem = selectedTransactions[key]; | ||
| if (selectedItem.action === CONST.SEARCH.ACTION_TYPES.VIEW && key === selectedItem.reportID) { | ||
| reportIDList.push(selectedItem.reportID); | ||
| } else { | ||
| } | ||
| } | ||
|
|
||
| // Collect transaction IDs, but exclude any transactions whose reportID is in the list of reports being deleted | ||
| for (const key of Object.keys(selectedTransactions)) { | ||
| const selectedItem = selectedTransactions[key]; | ||
| if (selectedItem.action === CONST.SEARCH.ACTION_TYPES.VIEW && key === selectedItem.reportID) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ CONSISTENCY-3 (docs)The condition Since the two-pass approach is needed (the second loop depends on the completed const reportIDSet = new Set<string>();
for (const key of Object.keys(selectedTransactions)) {
const selectedItem = selectedTransactions[key];
if (selectedItem.action === CONST.SEARCH.ACTION_TYPES.VIEW && key === selectedItem.reportID) {
reportIDSet.add(selectedItem.reportID);
}
}
const reportIDList = Array.from(reportIDSet);
for (const key of Object.keys(selectedTransactions)) {
if (reportIDSet.has(key)) {
continue;
}
const selectedItem = selectedTransactions[key];
if (\!selectedItem.reportID || \!reportIDSet.has(selectedItem.reportID)) {
transactionIDList.push(key);
}
}This removes the duplicated condition and the duplicated variable lookup, and as a bonus, using a Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency. |
||
| continue; | ||
| } | ||
| if (!selectedItem.reportID || !reportIDList.includes(selectedItem.reportID)) { | ||
| transactionIDList.push(key); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First pass: Collect all report IDs that are being deleted
Second pass: Collect transaction IDs, but exclude any transactions whose reportID is in the list of reports being deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add comments for the two loops?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added @eh2077