diff --git a/src/libs/ReceiptUtils.ts b/src/libs/ReceiptUtils.ts index e08d52f5f1f6..2fd0f2dd8621 100644 --- a/src/libs/ReceiptUtils.ts +++ b/src/libs/ReceiptUtils.ts @@ -37,9 +37,12 @@ function getThumbnailAndImageURIs(transaction: OnyxEntry, receiptPa // If there're errors, we need to display them in preview. We can store many files in errors, but we just need to get the last one const errors = findLast(transaction?.errors) as ReceiptError | undefined; // URI to image, i.e. blob:new.expensify.com/9ef3a018-4067-47c6-b29f-5f1bd35f213d or expensify.com/receipts/w_e616108497ef940b7210ec6beb5a462d01a878f4.jpg - const path = errors?.source ?? transaction?.receipt?.source ?? receiptPath ?? ''; + // When receipt.source is missing but filename exists (e.g. receipts added via email or billing), fall back to constructing the URL from the filename + const receiptFilename = transaction?.receipt?.filename; + const fallbackSource = !transaction?.receipt?.source && receiptFilename ? `https://www.expensify.com/receipts/${receiptFilename}` : undefined; + const path = errors?.source ?? transaction?.receipt?.source ?? fallbackSource ?? receiptPath ?? ''; // filename of uploaded image or last part of remote URI - const filename = errors?.filename ?? transaction?.receipt?.filename ?? receiptFileName ?? ''; + const filename = errors?.filename ?? receiptFilename ?? receiptFileName ?? ''; const isReceiptImage = Str.isImage(filename); const hasEReceipt = !hasReceiptSource(transaction) && transaction?.hasEReceipt; const isReceiptPDF = Str.isPDF(filename);