diff --git a/src/components/ReportActionItem/ReportPreview.tsx b/src/components/ReportActionItem/ReportPreview.tsx index ad29a8d84141..792ebb176900 100644 --- a/src/components/ReportActionItem/ReportPreview.tsx +++ b/src/components/ReportActionItem/ReportPreview.tsx @@ -305,7 +305,7 @@ function ReportPreview({ const shouldShowSettlementButton = (shouldShowPayButton || shouldShowApproveButton) && !showRTERViolationMessage; - const shouldPromptUserToAddBankAccount = ReportUtils.hasMissingPaymentMethod(userWallet, iouReportID); + const shouldPromptUserToAddBankAccount = ReportUtils.hasMissingPaymentMethod(userWallet, iouReportID) || ReportUtils.hasMissingInvoiceBankAccount(iouReportID); const shouldShowRBR = hasErrors; /* diff --git a/src/languages/en.ts b/src/languages/en.ts index 2363bb96a1b7..66d1e7c73c90 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -822,6 +822,7 @@ export default { managerApproved: ({manager}: ManagerApprovedParams) => `${manager} approved:`, managerApprovedAmount: ({manager, amount}: ManagerApprovedAmountParams) => `${manager} approved ${amount}`, payerSettled: ({amount}: PayerSettledParams) => `paid ${amount}`, + payerSettledWithMissingBankAccount: ({amount}: PayerSettledParams) => `paid ${amount}. Add a bank account to receive your payment.`, approvedAmount: ({amount}: ApprovedAmountParams) => `approved ${amount}`, forwardedAmount: ({amount}: ForwardedAmountParams) => `approved ${amount}`, rejectedThisReport: 'rejected this report', diff --git a/src/languages/es.ts b/src/languages/es.ts index 244ae16feb09..54402fd1d6d5 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -817,6 +817,7 @@ export default { managerApproved: ({manager}: ManagerApprovedParams) => `${manager} aprobó:`, managerApprovedAmount: ({manager, amount}: ManagerApprovedAmountParams) => `${manager} aprobó ${amount}`, payerSettled: ({amount}: PayerSettledParams) => `pagó ${amount}`, + payerSettledWithMissingBankAccount: ({amount}: PayerSettledParams) => `pagó ${amount}. Agrega una cuenta bancaria para recibir tu pago.`, approvedAmount: ({amount}: ApprovedAmountParams) => `aprobó ${amount}`, forwardedAmount: ({amount}: ForwardedAmountParams) => `aprobó ${amount}`, rejectedThisReport: 'rechazó este informe', diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8d940e3f0830..7b226b2e5c8e 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2596,6 +2596,18 @@ function requiresAttentionFromCurrentUser(optionOrReport: OnyxEntry | Op return true; } + if (hasMissingInvoiceBankAccount(optionOrReport.reportID)) { + return true; + } + + if (isInvoiceRoom(optionOrReport)) { + const invoiceRoomReportActions = ReportActionsUtils.getAllReportActions(optionOrReport.reportID); + + return Object.values(invoiceRoomReportActions).some( + (reportAction) => reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW && reportAction.childReportID && hasMissingInvoiceBankAccount(reportAction.childReportID), + ); + } + return false; } @@ -6920,7 +6932,7 @@ function getIOUReportActionDisplayMessage(reportAction: OnyxEntry, switch (originalMessage.paymentType) { case CONST.IOU.PAYMENT_TYPE.ELSEWHERE: - translationKey = 'iou.paidElsewhereWithAmount'; + translationKey = hasMissingInvoiceBankAccount(IOUReportID ?? '-1') ? 'iou.payerSettledWithMissingBankAccount' : 'iou.paidElsewhereWithAmount'; break; case CONST.IOU.PAYMENT_TYPE.EXPENSIFY: case CONST.IOU.PAYMENT_TYPE.VBBA: @@ -7750,6 +7762,19 @@ function getApprovalChain(policy: OnyxEntry, employeeAccountID: number, return approvalChain; } +/** + * Checks if the user has missing bank account for the invoice room. + */ +function hasMissingInvoiceBankAccount(iouReportID: string): boolean { + const invoiceReport = getReport(iouReportID); + + if (!isInvoiceReport(invoiceReport)) { + return false; + } + + return invoiceReport?.ownerAccountID === currentUserAccountID && isEmptyObject(getPolicy(invoiceReport?.policyID)?.invoice?.bankAccount ?? {}) && isSettled(iouReportID); +} + function isSubmittedExpenseReportManagerWithoutParentAccess(report: OnyxEntry) { return isExpenseReport(report) && report?.hasParentAccess === false && report?.managerID === currentUserAccountID && isProcessingReport(report); } @@ -8060,6 +8085,7 @@ export { getArchiveReason, getApprovalChain, isIndividualInvoiceRoom, + hasMissingInvoiceBankAccount, }; export type { diff --git a/src/pages/home/report/ReportActionItemMessage.tsx b/src/pages/home/report/ReportActionItemMessage.tsx index d88a6792f7c9..53d3b79de8ce 100644 --- a/src/pages/home/report/ReportActionItemMessage.tsx +++ b/src/pages/home/report/ReportActionItemMessage.tsx @@ -4,13 +4,16 @@ import type {StyleProp, TextStyle, ViewStyle} from 'react-native'; import {View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; +import Button from '@components/Button'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; import * as ReportActionsUtils from '@libs/ReportActionsUtils'; import * as ReportUtils from '@libs/ReportUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; import type {ReportAction, Transaction} from '@src/types/onyx'; import TextCommentFragment from './comment/TextCommentFragment'; import ReportActionItemFragment from './ReportActionItemFragment'; @@ -120,14 +123,36 @@ function ReportActionItemMessage({action, transaction, displayAsGroup, reportID, // Approving or submitting reports in oldDot results in system messages made up of multiple fragments of `TEXT` type // which we need to wrap in `` to prevent them rendering on separate lines. - return shouldWrapInText ? {reportActionItemFragments} : reportActionItemFragments; }; + const openWorkspaceInvoicesPage = () => { + const policyID = ReportUtils.getReport(reportID)?.policyID; + + if (!policyID) { + return; + } + + // TODO: Uncomment the following line when the invoices screen is ready - https://github.com/Expensify/App/issues/45175. + // Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policyID)) + Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID)); + }; + return ( {!isHidden ? ( - renderReportActionItemFragments(isApprovedOrSubmittedReportAction) + <> + {renderReportActionItemFragments(isApprovedOrSubmittedReportAction)} + {action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && ReportUtils.hasMissingInvoiceBankAccount(reportID) && ( +