Skip to content

Commit

Permalink
Merge pull request Expensify#34604 from paultsimura/fix/34287-pending…
Browse files Browse the repository at this point in the history
…-distance-receipt

fix: Return a generic receipt for pending distance requests
  • Loading branch information
MariaHCD authored Jan 23, 2024
2 parents 9c552ab + 051de07 commit 332a876
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/libs/ReceiptUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,28 @@ type FileNameAndExtension = {
* @param receiptFileName
*/
function getThumbnailAndImageURIs(transaction: Transaction, receiptPath: string | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI {
if (Object.hasOwn(transaction?.pendingFields ?? {}, 'waypoints')) {
return {thumbnail: null, image: ReceiptGeneric, isLocalFile: true};
}

// 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 ?? receiptPath ?? '';
// filename of uploaded image or last part of remote URI
const filename = transaction?.filename ?? receiptFileName ?? '';
const isReceiptImage = Str.isImage(filename);

const hasEReceipt = transaction?.hasEReceipt;

if (!Object.hasOwn(transaction?.pendingFields ?? {}, 'waypoints')) {
if (hasEReceipt) {
return {thumbnail: null, image: ROUTES.ERECEIPT.getRoute(transaction.transactionID), transaction};
}
if (hasEReceipt) {
return {thumbnail: null, image: ROUTES.ERECEIPT.getRoute(transaction.transactionID), transaction};
}

// For local files, we won't have a thumbnail yet
if (isReceiptImage && (path.startsWith('blob:') || path.startsWith('file:'))) {
return {thumbnail: null, image: path, isLocalFile: true};
}
// For local files, we won't have a thumbnail yet
if (isReceiptImage && (path.startsWith('blob:') || path.startsWith('file:'))) {
return {thumbnail: null, image: path, isLocalFile: true};
}

if (isReceiptImage) {
return {thumbnail: `${path}.1024.jpg`, image: path};
}
if (isReceiptImage) {
return {thumbnail: `${path}.1024.jpg`, image: path};
}

const {fileExtension} = FileUtils.splitExtensionFromFileName(filename) as FileNameAndExtension;
Expand Down

0 comments on commit 332a876

Please sign in to comment.