Skip to content

Commit

Permalink
Merge pull request #53802 from ikevin127/ikevin127-fixGBRSettledInvoice
Browse files Browse the repository at this point in the history
Fix: Remove GBR and 'Add a bank account' for paid invoices
  • Loading branch information
cristipaval authored Dec 19, 2024
2 parents 154a485 + 3af8319 commit 653a06b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ function ReportPreview({

const shouldShowSettlementButton = (shouldShowPayButton || shouldShowApproveButton) && !showRTERViolationMessage && !shouldShowBrokenConnectionViolation;

const shouldPromptUserToAddBankAccount = ReportUtils.hasMissingPaymentMethod(userWallet, iouReportID) || ReportUtils.hasMissingInvoiceBankAccount(iouReportID);
const shouldPromptUserToAddBankAccount =
(ReportUtils.hasMissingPaymentMethod(userWallet, iouReportID) || ReportUtils.hasMissingInvoiceBankAccount(iouReportID)) && !ReportUtils.isSettled(iouReportID);
const shouldShowRBR = hasErrors && !iouSettled;

/*
Expand Down
8 changes: 6 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2833,15 +2833,19 @@ function getReasonAndReportActionThatRequiresAttention(
};
}

if (hasMissingInvoiceBankAccount(optionOrReport.reportID)) {
if (hasMissingInvoiceBankAccount(optionOrReport.reportID) && !isSettled(optionOrReport.reportID)) {
return {
reason: CONST.REQUIRES_ATTENTION_REASONS.HAS_MISSING_INVOICE_BANK_ACCOUNT,
};
}

if (isInvoiceRoom(optionOrReport)) {
const reportAction = Object.values(reportActions).find(
(action) => action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && action.childReportID && hasMissingInvoiceBankAccount(action.childReportID),
(action) =>
action.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW &&
action.childReportID &&
hasMissingInvoiceBankAccount(action.childReportID) &&
!isSettled(action.childReportID),
);

return reportAction
Expand Down
4 changes: 3 additions & 1 deletion src/pages/home/report/ReportActionItemMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,14 @@ function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHid
Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policyID));
};

const shouldShowAddBankAccountButton = action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && ReportUtils.hasMissingInvoiceBankAccount(reportID) && !ReportUtils.isSettled(reportID);

return (
<View style={[styles.chatItemMessage, style]}>
{!isHidden ? (
<>
{renderReportActionItemFragments(isApprovedOrSubmittedReportAction)}
{action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && ReportUtils.hasMissingInvoiceBankAccount(reportID) && (
{shouldShowAddBankAccountButton && (
<Button
style={[styles.mt2, styles.alignSelfStart]}
success
Expand Down

0 comments on commit 653a06b

Please sign in to comment.