-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: Delete option is missing in More menu of an unpaid invoice report #73914
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
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 |
|---|---|---|
|
|
@@ -936,7 +936,7 @@ | |
| const parsedReportActionMessageCache: Record<string, string> = {}; | ||
|
|
||
| let conciergeReportID: OnyxEntry<string>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.CONCIERGE_REPORT_ID, | ||
| callback: (value) => { | ||
| conciergeReportID = value; | ||
|
|
@@ -944,7 +944,7 @@ | |
| }); | ||
|
|
||
| const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon'; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.SESSION, | ||
| callback: (value) => { | ||
| // When signed out, val is undefined | ||
|
|
@@ -962,7 +962,7 @@ | |
| let allPersonalDetails: OnyxEntry<PersonalDetailsList>; | ||
| let allPersonalDetailLogins: string[]; | ||
| let currentUserPersonalDetails: OnyxEntry<PersonalDetails>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| callback: (value) => { | ||
| if (currentUserAccountID) { | ||
|
|
@@ -974,14 +974,14 @@ | |
| }); | ||
|
|
||
| let allReportsDraft: OnyxCollection<Report>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_DRAFT, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => (allReportsDraft = value), | ||
| }); | ||
|
|
||
| let allPolicies: OnyxCollection<Policy>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.POLICY, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => (allPolicies = value), | ||
|
|
@@ -989,7 +989,7 @@ | |
|
|
||
| let allReports: OnyxCollection<Report>; | ||
| let reportsByPolicyID: ReportByPolicyMap; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -1030,14 +1030,14 @@ | |
| }); | ||
|
|
||
| let allBetas: OnyxEntry<Beta[]>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.BETAS, | ||
| callback: (value) => (allBetas = value), | ||
| }); | ||
|
|
||
| let allTransactions: OnyxCollection<Transaction> = {}; | ||
| let reportsTransactions: Record<string, Transaction[]> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.TRANSACTION, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -1063,7 +1063,7 @@ | |
| }); | ||
|
|
||
| let allReportActions: OnyxCollection<ReportActions>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, | ||
| waitForCollectionCallback: true, | ||
| callback: (actions) => { | ||
|
|
@@ -1076,7 +1076,7 @@ | |
|
|
||
| let allReportMetadata: OnyxCollection<ReportMetadata>; | ||
| const allReportMetadataKeyValue: Record<string, ReportMetadata> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_METADATA, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -2744,7 +2744,7 @@ | |
| } | ||
|
|
||
| if (isInvoiceReport(report)) { | ||
| return report?.ownerAccountID === currentUserAccountID && isReportOpenOrProcessing && policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONAL; | ||
| return report?.ownerAccountID === currentUserAccountID && isReportOpenOrProcessing; | ||
|
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. ✅ Change looks correct - Removes illogical constraintThe change fixes a bug where invoices could ONLY be deleted when workflows were ENABLED ( After the change, invoice deletion now follows the same pattern as IOU reports (line 2752-2753):
Security note: The The change is logically sound and aligns with the existing codebase patterns. |
||
| } | ||
|
|
||
| // Users cannot delete a report in the unreported or IOU cases, but they can delete individual transactions. | ||
|
|
||
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.
Question: Invoice deletion vs Expense Report deletion logic
The change simplifies invoice deletion by removing the
policy?.approvalMode !== CONST.POLICY.APPROVAL_MODE.OPTIONALcheck. This makes sense as the previous logic was counterintuitive - it required approval workflows to be enabled to delete invoices, which seems backwards.However, comparing this to the expense report deletion logic (lines 2756-2766), I notice expense reports have protection against deleting forwarded reports:
Question for reviewers: Should invoices have similar protection against deletion once they're in an approval workflow? Or are invoices intentionally different because they don't follow the same approval workflow as expense reports?
The current change allows invoice deletion based solely on:
This seems appropriate if invoices don't participate in approval workflows the same way expense reports do. But if they do, we might want to add the
!isForwardedcheck here as well for consistency.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.
The delete invoice flow doesn’t depend on the approval mode as mentioned.