Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ function AttachmentModal({
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const transactionID = (isMoneyRequestAction(parentReportAction) && getOriginalMessage(parentReportAction)?.IOUTransactionID) || CONST.DEFAULT_NUMBER_ID;
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {canBeMissing: true});
const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${report?.policyID}`, {canBeMissing: true});

const [currentAttachmentLink, setCurrentAttachmentLink] = useState(attachmentLink);
const {setAttachmentError, isErrorInAttachment, clearAttachmentErrors} = useAttachmentErrors();

Expand Down Expand Up @@ -292,10 +294,10 @@ function AttachmentModal({
* Detach the receipt and close the modal.
*/
const deleteAndCloseModal = useCallback(() => {
detachReceipt(transaction?.transactionID);
detachReceipt(transaction?.transactionID, policyCategories);
Comment thread
parasharrajat marked this conversation as resolved.
Resolved
setIsDeleteReceiptConfirmModalVisible(false);
Navigation.goBack();
}, [transaction]);
}, [transaction?.transactionID, policyCategories]);

/**
* Closes the modal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function TransactionReceiptModalContent({navigation, route}: AttachmentModalScre
const [transactionMain] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`, {canBeMissing: true});
const [transactionDraft] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {canBeMissing: true});
const [reportMetadata = CONST.DEFAULT_REPORT_METADATA] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, {canBeMissing: true});
const [policyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${report?.policyID}`, {canBeMissing: true});
Comment thread
parasharrajat marked this conversation as resolved.
Resolved

// If we have a merge transaction, we need to use the receipt from the merge transaction
const [mergeTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.MERGE_TRANSACTION}${mergeTransactionID}`, {canBeMissing: true});
Expand Down Expand Up @@ -139,9 +140,9 @@ function TransactionReceiptModalContent({navigation, route}: AttachmentModalScre
* Detach the receipt and close the modal.
*/
const deleteReceiptAndClose = useCallback(() => {
detachReceipt(transaction?.transactionID);
detachReceipt(transaction?.transactionID, policyCategories);
navigation.goBack();
}, [navigation, transaction?.transactionID]);
}, [navigation, transaction?.transactionID, policyCategories]);

const onDownloadAttachment = useDownloadAttachment({
isAuthTokenRequired,
Expand Down