Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 51 additions & 26 deletions src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -226,6 +230,7 @@ function MoneyRequestConfirmationList({
allPolicies,
action = CONST.IOU.ACTION.CREATE,
currencyList,
shouldDisplayReceipt = false,
}: MoneyRequestConfirmationListProps) {
const policy = policyReal ?? policyDraft;
const policyCategories = policyCategoriesReal ?? policyCategoriesDraft;
Expand Down Expand Up @@ -1096,33 +1101,49 @@ function MoneyRequestConfirmationList({
() => (
<View style={styles.moneyRequestImage}>
{isLocalFile && Str.isPDF(receiptFilename) ? (
<PDFThumbnail
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
previewSourceURL={resolvedReceiptImage as string}
// We don't support scanning password protected PDF receipt
enabled={!isAttachmentInvalid}
onPassword={() => {
setIsAttachmentInvalid(true);
setInvalidAttachmentPromt(translate('attachmentPicker.protectedPDFNotSupported'));
}}
onLoadError={() => {
setInvalidAttachmentPromt(translate('attachmentPicker.errorWhileSelectingCorruptedAttachment'));
setIsAttachmentInvalid(true);
}}
/>
<PressableWithoutFocus
onPress={() => Navigation.navigate(ROUTES.TRANSACTION_RECEIPT.getRoute(reportID ?? '', transactionID ?? ''))}
accessibilityRole={CONST.ROLE.BUTTON}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
disabled={!shouldDisplayReceipt}
disabledStyle={styles.cursorDefault}
>
<PDFThumbnail
// eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
previewSourceURL={resolvedReceiptImage as string}
// We don't support scanning password protected PDF receipt
enabled={!isAttachmentInvalid}
onPassword={() => {
setIsAttachmentInvalid(true);
setInvalidAttachmentPromt(translate('attachmentPicker.protectedPDFNotSupported'));
}}
onLoadError={() => {
setInvalidAttachmentPromt(translate('attachmentPicker.errorWhileSelectingCorruptedAttachment'));
setIsAttachmentInvalid(true);
}}
/>
</PressableWithoutFocus>
) : (
<ReceiptImage
isThumbnail={isThumbnail}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
source={resolvedThumbnail || resolvedReceiptImage || ''}
// AuthToken is required when retrieving the image from the server
// but we don't need it to load the blob:// or file:// image when starting an expense/split
// So if we have a thumbnail, it means we're retrieving the image from the server
isAuthTokenRequired={!!receiptThumbnail && !isLocalFile}
fileExtension={fileExtension}
shouldUseThumbnailImage
shouldUseInitialObjectPosition={isDistanceRequest}
/>
<PressableWithoutFocus
onPress={() => Navigation.navigate(ROUTES.TRANSACTION_RECEIPT.getRoute(reportID ?? '', transactionID ?? ''))}
disabled={!shouldDisplayReceipt || isThumbnail}
accessibilityRole={CONST.ROLE.BUTTON}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
disabledStyle={styles.cursorDefault}
>
<ReceiptImage
isThumbnail={isThumbnail}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
source={resolvedThumbnail || resolvedReceiptImage || ''}
// AuthToken is required when retrieving the image from the server
// but we don't need it to load the blob:// or file:// image when starting an expense/split
// So if we have a thumbnail, it means we're retrieving the image from the server
isAuthTokenRequired={!!receiptThumbnail && !isLocalFile}
fileExtension={fileExtension}
shouldUseThumbnailImage
shouldUseInitialObjectPosition={isDistanceRequest}
/>
</PressableWithoutFocus>
)}
</View>
),
Expand All @@ -1137,7 +1158,11 @@ function MoneyRequestConfirmationList({
receiptThumbnail,
fileExtension,
isDistanceRequest,
reportID,
transactionID,
translate,
styles.cursorDefault,
shouldDisplayReceipt,
],
);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/TransactionReceiptPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<AttachmentModal
Expand Down
1 change: 1 addition & 0 deletions src/pages/iou/SplitBillDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function SplitBillDetailsPage({personalDetails, report, route, reportActions, tr
iouCurrencyCode={splitCurrency}
iouComment={splitComment}
iouCreated={splitCreated}
shouldDisplayReceipt
iouMerchant={splitMerchant}
iouCategory={splitCategory}
iouIsBillable={splitBillable}
Expand Down