Repository navigation
Show payment details and stored names on invoices linked to bills #105968
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
44037a9
4ba6659
8f24355
788e08c
a0a796d
f1887c5
5a083b8
334328f
ba290e2
619f48f
56c5ea6
00d6b98
7dff9f7
f3ed2a5
adb58ef
90fdd84
6dc91f5
f3a3acc
caf465d
4112c03
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 |
|---|---|---|
|
|
@@ -1739,6 +1739,7 @@ function shouldReportActionBeVisible( | |
| reportID?: string, | ||
| isSupportTicketReport = false, | ||
| reportActions?: OnyxEntry<ReportActions>, | ||
| isInvoice?: boolean, | ||
| ): boolean { | ||
| if (!reportAction) { | ||
| return false; | ||
|
|
@@ -1812,10 +1813,12 @@ function shouldReportActionBeVisible( | |
| return false; | ||
| } | ||
|
|
||
| // Hide REIMBURSED and MARKED_REIMBURSED actions created from NewDot since an IOU PAY action is displayed instead | ||
| if (isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.REIMBURSED) || isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED)) { | ||
| const originalMessage = getOriginalMessage(reportAction); | ||
| if (originalMessage?.isNewDot || reportAction.shouldShow === false) { | ||
| // Hide REIMBURSED and MARKED_REIMBURSED actions created from NewDot since an IOU PAY action is displayed instead. | ||
| // ReimburseReport and MarkReimbursed add no IOU PAY action to an invoice, and neither does paying its linked bill, so the payment action stays visible on invoices. | ||
| // Auth sets shouldShow to false on MARKED_REIMBURSED actions created from NewDot for the same reason, so invoices ignore it too. | ||
| if (isPaymentRecordedByReimbursedAction(reportAction)) { | ||
| // Search passes isInvoice because its invoice can exist only in the Search snapshot, not in Onyx. | ||
| if (isPaymentActionHiddenOutsideInvoices(reportAction) && !(isInvoice ?? isInvoiceReportID(reportAction.reportID ?? reportID))) { | ||
|
Member
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. Why we are excluding invoices here? It feels like we are patching Auth bugs in App. Why don't we just use the
Contributor
Author
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. I'll do that in a follow up PR (and the update App as well) AI: Agreed, App shouldn't patch this. Auth https://github.com/Expensify/Auth/pull/26804 makes |
||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -1874,6 +1877,7 @@ function isReportActionVisible( | |
| // TODO: Remove optional (?) once all callers pass currentUserAccountID. Refactor issue: https://github.com/Expensify/App/issues/66408 | ||
| currentUserAccountID?: number, | ||
| reportActions?: OnyxEntry<ReportActions>, | ||
| isInvoice?: boolean, | ||
| ): boolean { | ||
| if (!reportAction?.reportActionID) { | ||
| return false; | ||
|
|
@@ -1885,18 +1889,45 @@ function isReportActionVisible( | |
| // from what's cached in visibleReportActions (which reflects persisted Onyx data). | ||
| // We must recalculate visibility at runtime to ensure accuracy for these transient states. | ||
| if (reportAction.pendingAction) { | ||
| return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction, currentUserAccountID, reportID, isSupportTicketReport, reportActions); | ||
| return shouldReportActionBeVisible( | ||
| reportAction, | ||
| reportAction.reportActionID, | ||
| canUserPerformWriteAction, | ||
| currentUserAccountID, | ||
| reportID, | ||
| isSupportTicketReport, | ||
| reportActions, | ||
| isInvoice, | ||
| ); | ||
| } | ||
|
|
||
| if (visibleReportActions && reportID) { | ||
| const reportCache = visibleReportActions[reportID]; | ||
| if (!reportCache) { | ||
| return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction, currentUserAccountID, reportID, isSupportTicketReport, reportActions); | ||
| return shouldReportActionBeVisible( | ||
| reportAction, | ||
| reportAction.reportActionID, | ||
| canUserPerformWriteAction, | ||
| currentUserAccountID, | ||
| reportID, | ||
| isSupportTicketReport, | ||
| reportActions, | ||
| isInvoice, | ||
| ); | ||
| } | ||
| const staticVisibility = reportCache[reportAction.reportActionID]; | ||
| // If action is not in derived value cache, fall back to runtime calculation | ||
| if (staticVisibility === undefined) { | ||
| return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction, currentUserAccountID, reportID, isSupportTicketReport, reportActions); | ||
| return shouldReportActionBeVisible( | ||
| reportAction, | ||
| reportAction.reportActionID, | ||
| canUserPerformWriteAction, | ||
| currentUserAccountID, | ||
| reportID, | ||
| isSupportTicketReport, | ||
| reportActions, | ||
| isInvoice, | ||
| ); | ||
| } | ||
| if (!staticVisibility) { | ||
| return false; | ||
|
|
@@ -1906,7 +1937,7 @@ function isReportActionVisible( | |
| } | ||
| return true; | ||
| } | ||
| return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction, currentUserAccountID, reportID, isSupportTicketReport, reportActions); | ||
| return shouldReportActionBeVisible(reportAction, reportAction.reportActionID, canUserPerformWriteAction, currentUserAccountID, reportID, isSupportTicketReport, reportActions, isInvoice); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -3559,6 +3590,27 @@ function isActionableCardFraudAlert(reportAction: OnyxInputOrEntry<ReportAction> | |
| return reportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_CARD_FRAUD_ALERT; | ||
| } | ||
|
|
||
| /** | ||
| * Whether the action records a payment that ReimburseReport or MarkReimbursed made | ||
| */ | ||
| function isPaymentRecordedByReimbursedAction( | ||
| reportAction: OnyxEntry<ReportAction>, | ||
| ): reportAction is ReportAction<typeof CONST.REPORT.ACTIONS.TYPE.REIMBURSED | typeof CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED> { | ||
| return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.REIMBURSED) || isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED); | ||
| } | ||
|
|
||
| function isInvoiceReportID(reportID: string | undefined): boolean { | ||
| return !!reportID && getReportOrDraftReport({reportID})?.type === CONST.REPORT.TYPE.INVOICE; | ||
| } | ||
|
|
||
| /** | ||
| * Returns true for a REIMBURSED or MARKED_REIMBURSED action that was created from NewDot or that Auth marked with | ||
| * shouldShow false. Such an action is hidden on every report except an invoice. | ||
| */ | ||
| function isPaymentActionHiddenOutsideInvoices(reportAction: OnyxEntry<ReportAction>): boolean { | ||
| return isPaymentRecordedByReimbursedAction(reportAction) && (!!getOriginalMessage(reportAction)?.isNewDot || reportAction.shouldShow === false); | ||
| } | ||
|
|
||
| /** | ||
| * Checks if a report action is an actionable whisper that requires write permission to be visible. | ||
| */ | ||
|
|
@@ -6502,6 +6554,7 @@ export { | |
| isActionableAddPaymentCard, | ||
| isActionableCardFraudAlert, | ||
| isActionableWhisperRequiringWritePermission, | ||
| isPaymentActionHiddenOutsideInvoices, | ||
| getExportIntegrationActionFragments, | ||
| getExportIntegrationLastMessageText, | ||
| getExportIntegrationMessageHTML, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.