Skip to content

Commit

Permalink
Access transactionID safely in case of pay IOU actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Li committed Aug 21, 2023
1 parent aad1961 commit b12644c
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as TransactionUtils from '../../../libs/TransactionUtils';
import * as ReceiptUtils from '../../../libs/ReceiptUtils';
import CONST from '../../../CONST';
import tryResolveUrlFromApiRoot from '../../../libs/tryResolveUrlFromApiRoot';
import lodashGet from 'lodash/get';

/**
* Constructs the initial component state from report actions
Expand Down Expand Up @@ -43,7 +44,12 @@ function extractAttachmentsFromReport(report, reportActions) {
// We're handling receipts differently here because receipt images are not
// part of the report action message, the images are constructed client-side
if (ReportActionsUtils.isMoneyRequestAction(action)) {
const transaction = TransactionUtils.getTransaction(action.originalMessage.IOUTransactionID);
const transactionID = lodashGet(action, ['originalMessage', 'IOUTransactionID']);
if (!transactionID) {
return;
}

const transaction = TransactionUtils.getTransaction(transactionID);
if (TransactionUtils.hasReceipt(transaction)) {
const {image} = ReceiptUtils.getThumbnailAndImageURIs(transaction.receipt.source, transaction.filename);
attachments.unshift({
Expand Down

0 comments on commit b12644c

Please sign in to comment.