Skip to content
Closed
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
7 changes: 5 additions & 2 deletions src/libs/ReceiptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ function getThumbnailAndImageURIs(transaction: OnyxEntry<Transaction>, 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);
Expand Down
Loading