diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index ba5c65a4fbd6..39021e86dd6d 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -52,6 +52,7 @@ import MenuItemWithTopDescription from './MenuItemWithTopDescription'; import MoneyRequestAmountInput from './MoneyRequestAmountInput'; import PDFThumbnail from './PDFThumbnail'; import {PressableWithFeedback} from './Pressable'; +import PressableWithoutFocus from './Pressable/PressableWithoutFocus'; import ReceiptEmptyState from './ReceiptEmptyState'; import ReceiptImage from './ReceiptImage'; import SelectionList from './SelectionList'; @@ -161,6 +162,9 @@ type MoneyRequestConfirmationListProps = MoneyRequestConfirmationListOnyxProps & /** Whether we're editing a split expense */ isEditingSplitBill?: boolean; + /** Whether we can navigate to receipt page */ + shouldDisplayReceipt?: boolean; + /** Whether we should show the amount, date, and merchant fields. */ shouldShowSmartScanFields?: boolean; @@ -226,6 +230,7 @@ function MoneyRequestConfirmationList({ allPolicies, action = CONST.IOU.ACTION.CREATE, currencyList, + shouldDisplayReceipt = false, }: MoneyRequestConfirmationListProps) { const policy = policyReal ?? policyDraft; const policyCategories = policyCategoriesReal ?? policyCategoriesDraft; @@ -1096,33 +1101,49 @@ function MoneyRequestConfirmationList({ () => ( {isLocalFile && Str.isPDF(receiptFilename) ? ( - { - setIsAttachmentInvalid(true); - setInvalidAttachmentPromt(translate('attachmentPicker.protectedPDFNotSupported')); - }} - onLoadError={() => { - setInvalidAttachmentPromt(translate('attachmentPicker.errorWhileSelectingCorruptedAttachment')); - setIsAttachmentInvalid(true); - }} - /> + Navigation.navigate(ROUTES.TRANSACTION_RECEIPT.getRoute(reportID ?? '', transactionID ?? ''))} + accessibilityRole={CONST.ROLE.BUTTON} + accessibilityLabel={translate('accessibilityHints.viewAttachment')} + disabled={!shouldDisplayReceipt} + disabledStyle={styles.cursorDefault} + > + { + setIsAttachmentInvalid(true); + setInvalidAttachmentPromt(translate('attachmentPicker.protectedPDFNotSupported')); + }} + onLoadError={() => { + setInvalidAttachmentPromt(translate('attachmentPicker.errorWhileSelectingCorruptedAttachment')); + setIsAttachmentInvalid(true); + }} + /> + ) : ( - + Navigation.navigate(ROUTES.TRANSACTION_RECEIPT.getRoute(reportID ?? '', transactionID ?? ''))} + disabled={!shouldDisplayReceipt || isThumbnail} + accessibilityRole={CONST.ROLE.BUTTON} + accessibilityLabel={translate('accessibilityHints.viewAttachment')} + disabledStyle={styles.cursorDefault} + > + + )} ), @@ -1137,7 +1158,11 @@ function MoneyRequestConfirmationList({ receiptThumbnail, fileExtension, isDistanceRequest, + reportID, + transactionID, translate, + styles.cursorDefault, + shouldDisplayReceipt, ], ); diff --git a/src/pages/TransactionReceiptPage.tsx b/src/pages/TransactionReceiptPage.tsx index eff94119ea2b..5721caf3e1a0 100644 --- a/src/pages/TransactionReceiptPage.tsx +++ b/src/pages/TransactionReceiptPage.tsx @@ -50,7 +50,7 @@ function TransactionReceipt({transaction, report, reportMetadata = {isLoadingIni const isTrackExpenseReport = ReportUtils.isTrackExpenseReport(report); // eslint-disable-next-line rulesdir/no-negated-variables - const shouldShowNotFoundPage = isTrackExpenseReport ? !transaction : (moneyRequestReportID ?? '') !== transaction?.reportID; + const shouldShowNotFoundPage = isTrackExpenseReport || transaction?.reportID === CONST.REPORT.SPLIT_REPORTID ? !transaction : (moneyRequestReportID ?? '') !== transaction?.reportID; return (