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
26 changes: 2 additions & 24 deletions src/components/AttachmentModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ import SafeAreaConsumer from './SafeAreaConsumer';
type AttachmentModalOnyxProps = {
/** The transaction associated with the receipt attachment, if any */
transaction: OnyxEntry<OnyxTypes.Transaction>;

/** The report associated with the receipt attachment, if any */
parentReport: OnyxEntry<OnyxTypes.Report>;

/** The policy associated with the receipt attachment, if any */
policy: OnyxEntry<OnyxTypes.Policy>;

/** The list of report actions associated with the receipt attachment, if any */
parentReportActions: OnyxEntry<OnyxTypes.ReportActions>;
};

type ImagePickerResponse = {
Expand Down Expand Up @@ -157,10 +148,7 @@ function AttachmentModal({
isWorkspaceAvatar = false,
maybeIcon = false,
transaction,
parentReport,
parentReportActions,
headerTitle,
policy,
children,
fallbackSource,
canEditReceipt = false,
Expand Down Expand Up @@ -413,7 +401,7 @@ function AttachmentModal({
const sourceForAttachmentView = sourceState || source;

const threeDotsMenuItems = useMemo(() => {
if (!isReceiptAttachment || !parentReport || !parentReportActions) {
if (!isReceiptAttachment) {
return [];
}

Expand Down Expand Up @@ -454,7 +442,7 @@ function AttachmentModal({
}
return menuItems;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isReceiptAttachment, parentReport, parentReportActions, policy, transaction, file, sourceState, iouType]);
}, [isReceiptAttachment, transaction, file, sourceState, iouType]);

// There are a few things that shouldn't be set until we absolutely know if the file is a receipt or an attachment.
// props.isReceiptAttachment will be null until its certain what the file is, in which case it will then be true|false.
Expand Down Expand Up @@ -621,16 +609,6 @@ export default withOnyx<AttachmentModalProps, AttachmentModalOnyxProps>({
},
initWithStoredValues: false,
},
parentReport: {
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT}${report ? report.parentReportID : '0'}`,
},
policy: {
key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report ? report.policyID : '0'}`,
},
parentReportActions: {
key: ({report}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report ? report.parentReportID : '0'}`,
canEvict: false,
},
})(memo(AttachmentModal));

export type {Attachment, FileObject, ImagePickerResponse};
Original file line number Diff line number Diff line change
Expand Up @@ -330,5 +330,6 @@ AttachmentPickerWithMenuItems.displayName = 'AttachmentPickerWithMenuItems';
export default withOnyx<AttachmentPickerWithMenuItemsProps, AttachmentPickerWithMenuItemsOnyxProps>({
policy: {
key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report?.policyID}`,
initialValue: {} as OnyxTypes.Policy,
},
})(AttachmentPickerWithMenuItems);