Skip to content

Commit ac33286

Browse files
authored
Merge pull request Expensify#76066 from etCoderDysto/fix_75045
fix: Download button on eReceipt opens not here page in another tab, crashes on Android
2 parents 0db980f + 12fe53a commit ac33286

File tree

1 file changed

+4
-2
lines changed
  • src/pages/media/AttachmentModalScreen/AttachmentModalBaseContent

1 file changed

+4
-2
lines changed

src/pages/media/AttachmentModalScreen/AttachmentModalBaseContent/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout';
2121
import useThemeStyles from '@hooks/useThemeStyles';
2222
import KeyboardShortcut from '@libs/KeyboardShortcut';
2323
import {getOriginalMessage, getReportAction, isMoneyRequestAction} from '@libs/ReportActionsUtils';
24+
import {hasEReceipt, hasReceiptSource} from '@libs/TransactionUtils';
2425
import type {AvatarSource} from '@libs/UserAvatarUtils';
2526
import variables from '@styles/variables';
2627
import CONST from '@src/CONST';
@@ -185,14 +186,15 @@ function AttachmentModalBaseContent({
185186
}, [clearAttachmentErrors]);
186187

187188
const {isAttachmentLoaded} = useContext(AttachmentStateContext);
189+
const isEReceipt = transaction && !hasReceiptSource(transaction) && hasEReceipt(transaction);
188190
const shouldShowDownloadButton = useMemo(() => {
189191
const isValidContext = !isEmptyObject(report) || type === CONST.ATTACHMENT_TYPE.SEARCH;
190-
if (!isValidContext || isErrorInAttachment(source)) {
192+
if (!isValidContext || isErrorInAttachment(source) || isEReceipt) {
191193
return false;
192194
}
193195

194196
return !!onDownloadAttachment && isDownloadButtonReadyToBeShown && !shouldShowNotFoundPage && !isOffline && !isLocalSource && isAttachmentLoaded?.(source);
195-
}, [isAttachmentLoaded, isDownloadButtonReadyToBeShown, isErrorInAttachment, isLocalSource, isOffline, onDownloadAttachment, report, shouldShowNotFoundPage, source, type]);
197+
}, [isAttachmentLoaded, isDownloadButtonReadyToBeShown, isErrorInAttachment, isLocalSource, isOffline, onDownloadAttachment, report, shouldShowNotFoundPage, source, type, isEReceipt]);
196198

197199
// We need to pass a shared value of type boolean to the context, so `falseSV` acts as a default value.
198200
const falseSV = useSharedValue(false);

0 commit comments

Comments
 (0)