Skip to content

Commit

Permalink
Merge pull request #29873 from c3024/29855-receipt-missing-in-preview
Browse files Browse the repository at this point in the history
get image from IOU when there is no source in transaction
  • Loading branch information
cristipaval authored Oct 18, 2023
2 parents 113a64c + a5f04ac commit 4a1e2b3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,8 @@ function MoneyRequestConfirmationList(props) {
);
}, [confirm, props.bankAccountRoute, props.iouCurrencyCode, props.iouType, props.isReadOnly, props.policyID, selectedParticipants, splitOrRequestOptions, translate, formError]);

const {image: receiptImage, thumbnail: receiptThumbnail} = props.receiptPath && props.receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction) : {};
const {image: receiptImage, thumbnail: receiptThumbnail} =
props.receiptPath && props.receiptFilename ? ReceiptUtils.getThumbnailAndImageURIs(transaction, props.receiptPath, props.receiptFilename) : {};

return (
<OptionsSelector
Expand Down
8 changes: 5 additions & 3 deletions src/libs/ReceiptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ type FileNameAndExtension = {
* Grab the appropriate receipt image and thumbnail URIs based on file type
*
* @param transaction
* @param receiptPath
* @param receiptFileName
*/
function getThumbnailAndImageURIs(transaction: Transaction): ThumbnailAndImageURI {
function getThumbnailAndImageURIs(transaction: Transaction, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI {
// URI to image, i.e. blob:new.expensify.com/9ef3a018-4067-47c6-b29f-5f1bd35f213d or expensify.com/receipts/w_e616108497ef940b7210ec6beb5a462d01a878f4.jpg
const path = transaction?.receipt?.source ?? '';
const path = transaction?.receipt?.source ?? receiptPath ?? '';
// filename of uploaded image or last part of remote URI
const filename = transaction?.filename ?? '';
const filename = transaction?.filename ?? receiptFileName ?? '';
const isReceiptImage = Str.isImage(filename);

const hasEReceipt = transaction?.hasEReceipt;
Expand Down

0 comments on commit 4a1e2b3

Please sign in to comment.