From a6f17d785c453c3074e232068e7d35f81e3b906c Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Fri, 8 Aug 2025 17:42:41 +0200 Subject: [PATCH 01/13] should work on some cases --- src/ONYXKEYS.ts | 4 ++++ src/libs/actions/Share.ts | 13 ++++++++---- src/pages/Share/ShareDetailsPage.tsx | 23 ++++++--------------- src/pages/Share/ShareRootPage.tsx | 29 +++++++++++++++++++++++++-- src/pages/Share/SubmitDetailsPage.tsx | 22 +++++--------------- src/types/onyx/index.ts | 2 ++ 6 files changed, 53 insertions(+), 40 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index dbc230c4f48b1..911f1b45512aa 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -1,5 +1,6 @@ import type {OnyxUpdate} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; +import type {FileObject} from './components/AttachmentModal'; import type CONST from './CONST'; import type {OnboardingAccounting} from './CONST'; import type {OnboardingCompanySize} from './libs/actions/Welcome/OnboardingFlow'; @@ -498,6 +499,8 @@ const ONYXKEYS = { /** Temporary file to be shared from outside the app */ SHARE_TEMP_FILE: 'shareTempFile', + SHARE_FILE_OBJECT: 'shareFileObject', + /** Corpay fields to be used in the bank account creation setup */ CORPAY_FIELDS: 'corpayFields', @@ -1197,6 +1200,7 @@ type OnyxValuesMapping = { [ONYXKEYS.CONCIERGE_REPORT_ID]: string; [ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS]: Participant; [ONYXKEYS.SHARE_TEMP_FILE]: OnyxTypes.ShareTempFile; + [ONYXKEYS.SHARE_FILE_OBJECT]: OnyxTypes.FileObject[]; [ONYXKEYS.CORPAY_FIELDS]: OnyxTypes.CorpayFields; [ONYXKEYS.PRESERVED_USER_SESSION]: OnyxTypes.Session; [ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING]: OnyxTypes.DismissedProductTraining; diff --git a/src/libs/actions/Share.ts b/src/libs/actions/Share.ts index 6341b30766e6a..ee56b4a2ed361 100644 --- a/src/libs/actions/Share.ts +++ b/src/libs/actions/Share.ts @@ -1,9 +1,10 @@ import Onyx from 'react-native-onyx'; +import type {FileObject} from '@components/AttachmentModal'; import ONYXKEYS from '@src/ONYXKEYS'; import type {ShareTempFile} from '@src/types/onyx'; import type {Participant} from '@src/types/onyx/IOU'; -/** +/** Function for clearing old saved data before at the start of share-extension flow */ function clearShareData() { @@ -13,7 +14,7 @@ function clearShareData() { }); } -/** +/** Function storing natively shared file's properties for processing across share-extension screens function addTempShareFile(file: ShareTempFile) { @@ -23,7 +24,11 @@ function addTempShareFile(file: ShareTempFile) { Onyx.merge(ONYXKEYS.SHARE_TEMP_FILE, file); } -/** +function addValidatedShareFile(file: FileObject[]) { + Onyx.set(ONYXKEYS.SHARE_FILE_OBJECT, file); +} + +/** Function storing selected user's details for the duration of share-extension flow, if account doesn't exist * @param user selected user's details @@ -32,4 +37,4 @@ function saveUnknownUserDetails(user: Participant) { Onyx.merge(ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS, user); } -export {addTempShareFile, saveUnknownUserDetails, clearShareData}; +export {addTempShareFile, saveUnknownUserDetails, clearShareData, addValidatedShareFile}; diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index 808e2781a7fea..545d33f2aec85 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -2,7 +2,6 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useEffect, useMemo, useState} from 'react'; import {SafeAreaView, View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; -import type {FileObject} from '@components/AttachmentModal'; import AttachmentModal from '@components/AttachmentModal'; import AttachmentPreview from '@components/AttachmentPreview'; import Button from '@components/Button'; @@ -14,7 +13,6 @@ import ScreenWrapper from '@components/ScreenWrapper'; import ScrollView from '@components/ScrollView'; import Text from '@components/Text'; import TextInput from '@components/TextInput'; -import useFilesValidation from '@hooks/useFilesValidation'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -49,26 +47,17 @@ function ShareDetailsPage({ const {translate} = useLocalize(); const [unknownUserDetails] = useOnyx(ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS, {canBeMissing: true}); const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); + const [validFilesToUpload] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: false}); + const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); const isTextShared = currentAttachment?.mimeType === 'txt'; const [message, setMessage] = useState(isTextShared ? (currentAttachment?.content ?? '') : ''); const [errorTitle, setErrorTitle] = useState(undefined); const [errorMessage, setErrorMessage] = useState(undefined); - const [validFilesToUpload, setValidFilesToUpload] = useState([]); - const {validateFiles} = useFilesValidation(setValidFilesToUpload); - const report: OnyxEntry = getReportOrDraftReport(reportOrAccountID); const displayReport = useMemo(() => getReportDisplayOption(report, unknownUserDetails, reportAttributesDerived), [report, unknownUserDetails, reportAttributesDerived]); - useEffect(() => { - if (!currentAttachment || isTextShared || validFilesToUpload.length !== 0) { - return; - } - - validateFiles([{name: currentAttachment.id, uri: currentAttachment.content, type: currentAttachment.mimeType}]); - }, [currentAttachment, isTextShared, validFilesToUpload.length, validateFiles]); - useEffect(() => { if (!currentAttachment?.content || errorTitle) { return; @@ -105,7 +94,7 @@ function ShareDetailsPage({ const fileName = currentAttachment?.content.split('/').pop(); const handleShare = () => { - if (!currentAttachment || validFilesToUpload.length === 0) { + if (!currentAttachment || (!!validFilesToUpload && validFilesToUpload.length === 0)) { return; } @@ -116,7 +105,7 @@ function ShareDetailsPage({ return; } - const validatedFile = validFilesToUpload.at(0); + const validatedFile = validFilesToUpload?.at(0); readFileAsync( validatedFile?.uri ?? '', getFileName(validatedFile?.uri ?? 'shared_image.png'), @@ -211,13 +200,13 @@ function ShareDetailsPage({ {({show}) => ( { diff --git a/src/pages/Share/ShareRootPage.tsx b/src/pages/Share/ShareRootPage.tsx index 962b47df7daab..c00e00e014eb2 100644 --- a/src/pages/Share/ShareRootPage.tsx +++ b/src/pages/Share/ShareRootPage.tsx @@ -5,9 +5,11 @@ import type {AnimatedTextInputRef} from '@components/RNTextInput'; import ScreenWrapper from '@components/ScreenWrapper'; import TabNavigatorSkeleton from '@components/Skeletons/TabNavigatorSkeleton'; import TabSelector from '@components/TabSelector/TabSelector'; +import useFilesValidation from '@hooks/useFilesValidation'; import useLocalize from '@hooks/useLocalize'; +import useOnyx from '@hooks/useOnyx'; import useThemeStyles from '@hooks/useThemeStyles'; -import {addTempShareFile, clearShareData} from '@libs/actions/Share'; +import {addTempShareFile, addValidatedShareFile, clearShareData} from '@libs/actions/Share'; import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import {splitExtensionFromFileName, validateImageForCorruption} from '@libs/fileDownload/FileUtils'; import Navigation from '@libs/Navigation/Navigation'; @@ -15,6 +17,7 @@ import OnyxTabNavigator, {TopTab} from '@libs/Navigation/OnyxTabNavigator'; import ShareActionHandler from '@libs/ShareActionHandlerModule'; import type {FileObject} from '@pages/media/AttachmentModalScreen/types'; import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type {ShareTempFile} from '@src/types/onyx'; import getFileSize from './getFileSize'; @@ -33,6 +36,26 @@ function showErrorAlert(title: string, message: string) { } function ShareRootPage() { + const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); + const [validatedFile] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: true}); + + const {validateFiles} = useFilesValidation(addValidatedShareFile); + const isTextShared = currentAttachment?.mimeType === 'txt'; + + const validateFilesWrapper = useCallback(() => { + if (!currentAttachment || isTextShared || validatedFile?.length !== 0) { + return; + } + + validateFiles([ + { + name: currentAttachment.id, + uri: currentAttachment.content, + type: currentAttachment.mimeType, + }, + ]); + }, [currentAttachment, isTextShared, validatedFile, validateFiles]); + const appState = useRef(AppState.currentState); const [isFileReady, setIsFileReady] = useState(false); @@ -107,6 +130,7 @@ function ShareRootPage() { const subscription = AppState.addEventListener('change', (nextAppState) => { if (appState.current.match(/inactive|background/) && nextAppState === 'active') { handleProcessFiles(); + validateFilesWrapper(); } appState.current = nextAppState; @@ -115,11 +139,12 @@ function ShareRootPage() { return () => { subscription.remove(); }; - }, [handleProcessFiles]); + }, [handleProcessFiles, validateFilesWrapper]); useEffect(() => { clearShareData(); handleProcessFiles(); + validateFilesWrapper(); // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, []); diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index c0cfa0270e60d..6808071015085 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -2,14 +2,12 @@ import type {StackScreenProps} from '@react-navigation/stack'; import React, {useEffect, useState} from 'react'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; -import type {FileObject} from '@components/AttachmentModal'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import LocationPermissionModal from '@components/LocationPermissionModal'; import MoneyRequestConfirmationList from '@components/MoneyRequestConfirmationList'; import ScreenWrapper from '@components/ScreenWrapper'; import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; -import useFilesValidation from '@hooks/useFilesValidation'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; import usePermissions from '@hooks/usePermissions'; @@ -42,7 +40,6 @@ function SubmitDetailsPage({ }: ShareDetailsPageProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); const [unknownUserDetails] = useOnyx(ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS, {canBeMissing: true}); const [personalDetails] = useOnyx(`${ONYXKEYS.PERSONAL_DETAILS_LIST}`, {canBeMissing: true}); const report: OnyxEntry = getReportOrDraftReport(reportOrAccountID); @@ -53,6 +50,8 @@ function SubmitDetailsPage({ const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getIOURequestPolicyID(transaction, report)}`, {canBeMissing: false}); const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: false}); const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); + const [validFilesToUpload] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: false}); + const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); @@ -62,17 +61,6 @@ function SubmitDetailsPage({ const {isBetaEnabled} = usePermissions(); const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS); - const [validFilesToUpload, setValidFilesToUpload] = useState([]); - const {validateFiles} = useFilesValidation(setValidFilesToUpload); - - useEffect(() => { - if (!currentAttachment || validFilesToUpload.length !== 0) { - return; - } - - validateFiles([{name: currentAttachment.id, uri: currentAttachment.content, type: currentAttachment.mimeType}]); - }, [currentAttachment, validFilesToUpload.length, validateFiles]); - useEffect(() => { if (!errorTitle || !errorMessage) { return; @@ -202,7 +190,7 @@ function SubmitDetailsPage({ return; } - const validatedFile = validFilesToUpload.at(0); + const validatedFile = validFilesToUpload?.at(0); readFileAsync( validatedFile?.uri ?? '', getFileName(validatedFile?.name ?? 'shared_image.png'), @@ -239,8 +227,8 @@ function SubmitDetailsPage({ iouComment={trimmedComment} iouCategory={transaction?.category} onConfirm={() => onConfirm(true)} - receiptPath={validFilesToUpload.at(0)?.uri} - receiptFilename={getFileName(validFilesToUpload.at(0)?.name ?? '')} + receiptPath={validFilesToUpload?.at(0)?.uri} + receiptFilename={getFileName(validFilesToUpload?.at(0)?.name ?? '')} reportID={reportOrAccountID} shouldShowSmartScanFields={false} isDistanceRequest={false} diff --git a/src/types/onyx/index.ts b/src/types/onyx/index.ts index a0185b731e3a3..a56695f410ea3 100644 --- a/src/types/onyx/index.ts +++ b/src/types/onyx/index.ts @@ -1,3 +1,4 @@ +import type {FileObject} from '@components/AttachmentModal'; import type {OnboardingPurpose} from '@libs/actions/Welcome/OnboardingFlow'; import type Account from './Account'; import type AccountData from './AccountData'; @@ -124,6 +125,7 @@ import type WalletTerms from './WalletTerms'; import type WalletTransfer from './WalletTransfer'; export type { + FileObject, TryNewDot, Account, AccountData, From 60937434ee500fee654ec2dde842a5c56b7ec056 Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Tue, 12 Aug 2025 11:50:34 +0200 Subject: [PATCH 02/13] work in progress --- src/pages/Share/ShareDetailsPage.tsx | 2 +- src/pages/Share/SubmitDetailsPage.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index 545d33f2aec85..366c7ab58d186 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -47,7 +47,7 @@ function ShareDetailsPage({ const {translate} = useLocalize(); const [unknownUserDetails] = useOnyx(ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS, {canBeMissing: true}); const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); - const [validFilesToUpload] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: false}); + const [validFilesToUpload] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: true}); const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); const isTextShared = currentAttachment?.mimeType === 'txt'; diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index 6808071015085..d662863b0e532 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -50,7 +50,7 @@ function SubmitDetailsPage({ const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getIOURequestPolicyID(transaction, report)}`, {canBeMissing: false}); const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: false}); const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); - const [validFilesToUpload] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: false}); + const [validFilesToUpload] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: true}); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); From 2c391e7e0ee2f41c3525996bd0236383275a2bcb Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Tue, 12 Aug 2025 14:17:22 +0200 Subject: [PATCH 03/13] working moved logic --- src/pages/Share/ShareRootPage.tsx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/pages/Share/ShareRootPage.tsx b/src/pages/Share/ShareRootPage.tsx index c00e00e014eb2..a32efc07c91e1 100644 --- a/src/pages/Share/ShareRootPage.tsx +++ b/src/pages/Share/ShareRootPage.tsx @@ -37,24 +37,28 @@ function showErrorAlert(title: string, message: string) { function ShareRootPage() { const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); - const [validatedFile] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: true}); + // const [validatedFile] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: true}); const {validateFiles} = useFilesValidation(addValidatedShareFile); const isTextShared = currentAttachment?.mimeType === 'txt'; - const validateFilesWrapper = useCallback(() => { - if (!currentAttachment || isTextShared || validatedFile?.length !== 0) { + const validateFilesWrapper = (file: ShareTempFile) => { + console.log('___________________________________'); + console.log('nowe foto', currentAttachment); + console.log('___________________________________'); + + if (!file || isTextShared) { return; } validateFiles([ { - name: currentAttachment.id, - uri: currentAttachment.content, - type: currentAttachment.mimeType, + name: file.id, + uri: file.content, + type: file.mimeType, }, ]); - }, [currentAttachment, isTextShared, validatedFile, validateFiles]); + }; const appState = useRef(AppState.currentState); const [isFileReady, setIsFileReady] = useState(false); @@ -122,6 +126,7 @@ function ShareRootPage() { } addTempShareFile(tempFile); + validateFilesWrapper(tempFile); } }); }, [receiptFileFormats, shareFileMimeTypes, translate, errorTitle]); @@ -130,7 +135,6 @@ function ShareRootPage() { const subscription = AppState.addEventListener('change', (nextAppState) => { if (appState.current.match(/inactive|background/) && nextAppState === 'active') { handleProcessFiles(); - validateFilesWrapper(); } appState.current = nextAppState; @@ -139,12 +143,11 @@ function ShareRootPage() { return () => { subscription.remove(); }; - }, [handleProcessFiles, validateFilesWrapper]); + }, [handleProcessFiles]); useEffect(() => { clearShareData(); handleProcessFiles(); - validateFilesWrapper(); // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, []); From 298ecbbaef9c892e1ccd64f55a75b4b7304342d2 Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Tue, 12 Aug 2025 15:04:58 +0200 Subject: [PATCH 04/13] fix pdf and other types files --- src/pages/Share/ShareDetailsPage.tsx | 12 +++++++++--- src/pages/Share/ShareRootPage.tsx | 5 ----- src/pages/Share/SubmitDetailsPage.tsx | 16 +++++++++++++--- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index 366c7ab58d186..92f2483764488 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -51,6 +51,7 @@ function ShareDetailsPage({ const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); const isTextShared = currentAttachment?.mimeType === 'txt'; + const shouldUsePreValidatedFile = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC; const [message, setMessage] = useState(isTextShared ? (currentAttachment?.content ?? '') : ''); const [errorTitle, setErrorTitle] = useState(undefined); const [errorMessage, setErrorMessage] = useState(undefined); @@ -106,9 +107,14 @@ function ShareDetailsPage({ } const validatedFile = validFilesToUpload?.at(0); + + const fileUri = shouldUsePreValidatedFile ? (validatedFile?.uri ?? '') : currentAttachment.content; + const fileNamed = shouldUsePreValidatedFile ? getFileName(validatedFile?.uri ?? 'shared_image.png') : getFileName(currentAttachment.content); + const fileType = shouldUsePreValidatedFile ? (validatedFile?.type ?? 'image/jpeg') : currentAttachment.mimeType; + readFileAsync( - validatedFile?.uri ?? '', - getFileName(validatedFile?.uri ?? 'shared_image.png'), + fileUri, + fileNamed, (file) => { if (isDraft) { openReport( @@ -129,7 +135,7 @@ function ShareDetailsPage({ Navigation.navigate(routeToNavigate, {forceReplace: true}); }, () => {}, - validatedFile?.type ?? 'image/jpeg', + fileType, ); }; diff --git a/src/pages/Share/ShareRootPage.tsx b/src/pages/Share/ShareRootPage.tsx index a32efc07c91e1..cebc059c9cd31 100644 --- a/src/pages/Share/ShareRootPage.tsx +++ b/src/pages/Share/ShareRootPage.tsx @@ -37,16 +37,11 @@ function showErrorAlert(title: string, message: string) { function ShareRootPage() { const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); - // const [validatedFile] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: true}); const {validateFiles} = useFilesValidation(addValidatedShareFile); const isTextShared = currentAttachment?.mimeType === 'txt'; const validateFilesWrapper = (file: ShareTempFile) => { - console.log('___________________________________'); - console.log('nowe foto', currentAttachment); - console.log('___________________________________'); - if (!file || isTextShared) { return; } diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index d662863b0e532..f93681e6d78f5 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -51,6 +51,8 @@ function SubmitDetailsPage({ const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: false}); const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); const [validFilesToUpload] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: true}); + const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); + const shouldUsePreValidatedFile = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC; const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); @@ -189,14 +191,22 @@ function SubmitDetailsPage({ setStartLocationPermissionFlow(true); return; } + if (!currentAttachment) { + return; + } const validatedFile = validFilesToUpload?.at(0); + + const fileUri = shouldUsePreValidatedFile ? (validatedFile?.uri ?? '') : currentAttachment.content; + const fileNamed = shouldUsePreValidatedFile ? getFileName(validatedFile?.uri ?? 'shared_image.png') : getFileName(currentAttachment.content); + const fileType = shouldUsePreValidatedFile ? (validatedFile?.type ?? 'image/jpeg') : currentAttachment.mimeType; + readFileAsync( - validatedFile?.uri ?? '', - getFileName(validatedFile?.name ?? 'shared_image.png'), + fileUri, + fileNamed, (file) => onSuccess(file, shouldStartLocationPermissionFlow), () => {}, - validatedFile?.type ?? 'image/jpeg', + fileType, ); }; From 11b2e55dbe8c90df51f24c2f2dbc14a7aca4a86f Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Tue, 12 Aug 2025 15:17:47 +0200 Subject: [PATCH 05/13] full working solution --- src/pages/Share/ShareDetailsPage.tsx | 17 ++++++++--------- src/pages/Share/SubmitDetailsPage.tsx | 17 ++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index 92f2483764488..ebc3c97d19a34 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -48,6 +48,7 @@ function ShareDetailsPage({ const [unknownUserDetails] = useOnyx(ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS, {canBeMissing: true}); const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); const [validFilesToUpload] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: true}); + const validatedFile = validFilesToUpload?.at(0); const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); const isTextShared = currentAttachment?.mimeType === 'txt'; @@ -59,6 +60,10 @@ function ShareDetailsPage({ const report: OnyxEntry = getReportOrDraftReport(reportOrAccountID); const displayReport = useMemo(() => getReportDisplayOption(report, unknownUserDetails, reportAttributesDerived), [report, unknownUserDetails, reportAttributesDerived]); + const fileUri = shouldUsePreValidatedFile ? (validatedFile?.uri ?? '') : (currentAttachment?.content ?? ''); + const validateFileName = shouldUsePreValidatedFile ? getFileName(validatedFile?.uri ?? 'shared_image.png') : getFileName(currentAttachment?.content ?? ''); + const fileType = shouldUsePreValidatedFile ? (validatedFile?.type ?? 'image/jpeg') : (currentAttachment?.mimeType ?? ''); + useEffect(() => { if (!currentAttachment?.content || errorTitle) { return; @@ -106,15 +111,9 @@ function ShareDetailsPage({ return; } - const validatedFile = validFilesToUpload?.at(0); - - const fileUri = shouldUsePreValidatedFile ? (validatedFile?.uri ?? '') : currentAttachment.content; - const fileNamed = shouldUsePreValidatedFile ? getFileName(validatedFile?.uri ?? 'shared_image.png') : getFileName(currentAttachment.content); - const fileType = shouldUsePreValidatedFile ? (validatedFile?.type ?? 'image/jpeg') : currentAttachment.mimeType; - readFileAsync( fileUri, - fileNamed, + validateFileName, (file) => { if (isDraft) { openReport( @@ -206,13 +205,13 @@ function ShareDetailsPage({ {({show}) => ( { diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index f93681e6d78f5..5445c83193b51 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -53,6 +53,7 @@ function SubmitDetailsPage({ const [validFilesToUpload] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: true}); const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); const shouldUsePreValidatedFile = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC; + const validatedFile = validFilesToUpload?.at(0); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); @@ -63,6 +64,10 @@ function SubmitDetailsPage({ const {isBetaEnabled} = usePermissions(); const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS); + const fileUri = shouldUsePreValidatedFile ? (validatedFile?.uri ?? '') : (currentAttachment?.content ?? ''); + const fileName = shouldUsePreValidatedFile ? getFileName(validatedFile?.uri ?? 'shared_image.png') : getFileName(currentAttachment?.content ?? ''); + const fileType = shouldUsePreValidatedFile ? (validatedFile?.type ?? 'image/jpeg') : (currentAttachment?.mimeType ?? ''); + useEffect(() => { if (!errorTitle || !errorMessage) { return; @@ -195,15 +200,9 @@ function SubmitDetailsPage({ return; } - const validatedFile = validFilesToUpload?.at(0); - - const fileUri = shouldUsePreValidatedFile ? (validatedFile?.uri ?? '') : currentAttachment.content; - const fileNamed = shouldUsePreValidatedFile ? getFileName(validatedFile?.uri ?? 'shared_image.png') : getFileName(currentAttachment.content); - const fileType = shouldUsePreValidatedFile ? (validatedFile?.type ?? 'image/jpeg') : currentAttachment.mimeType; - readFileAsync( fileUri, - fileNamed, + fileName, (file) => onSuccess(file, shouldStartLocationPermissionFlow), () => {}, fileType, @@ -237,8 +236,8 @@ function SubmitDetailsPage({ iouComment={trimmedComment} iouCategory={transaction?.category} onConfirm={() => onConfirm(true)} - receiptPath={validFilesToUpload?.at(0)?.uri} - receiptFilename={getFileName(validFilesToUpload?.at(0)?.name ?? '')} + receiptPath={fileUri} + receiptFilename={getFileName(fileName)} reportID={reportOrAccountID} shouldShowSmartScanFields={false} isDistanceRequest={false} From db7d30fa810777aade613df3ba615f16b6c5b933 Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Tue, 12 Aug 2025 15:41:16 +0200 Subject: [PATCH 06/13] cleanUp and refactor --- src/ONYXKEYS.ts | 4 ++-- src/libs/actions/Share.ts | 7 ++++++- src/pages/Share/ShareDetailsPage.tsx | 2 +- src/pages/Share/SubmitDetailsPage.tsx | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 911f1b45512aa..410697b340985 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -499,7 +499,7 @@ const ONYXKEYS = { /** Temporary file to be shared from outside the app */ SHARE_TEMP_FILE: 'shareTempFile', - SHARE_FILE_OBJECT: 'shareFileObject', + VALIDATED_FILE_OBJECT: 'shareFileObject', /** Corpay fields to be used in the bank account creation setup */ CORPAY_FIELDS: 'corpayFields', @@ -1200,7 +1200,7 @@ type OnyxValuesMapping = { [ONYXKEYS.CONCIERGE_REPORT_ID]: string; [ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS]: Participant; [ONYXKEYS.SHARE_TEMP_FILE]: OnyxTypes.ShareTempFile; - [ONYXKEYS.SHARE_FILE_OBJECT]: OnyxTypes.FileObject[]; + [ONYXKEYS.VALIDATED_FILE_OBJECT]: OnyxTypes.FileObject[]; [ONYXKEYS.CORPAY_FIELDS]: OnyxTypes.CorpayFields; [ONYXKEYS.PRESERVED_USER_SESSION]: OnyxTypes.Session; [ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING]: OnyxTypes.DismissedProductTraining; diff --git a/src/libs/actions/Share.ts b/src/libs/actions/Share.ts index ee56b4a2ed361..a499384556208 100644 --- a/src/libs/actions/Share.ts +++ b/src/libs/actions/Share.ts @@ -24,8 +24,13 @@ function addTempShareFile(file: ShareTempFile) { Onyx.merge(ONYXKEYS.SHARE_TEMP_FILE, file); } +/** + * Stores a previously validated file object in Onyx for further use. + * + * @param file Array of validated file objects to be saved + */ function addValidatedShareFile(file: FileObject[]) { - Onyx.set(ONYXKEYS.SHARE_FILE_OBJECT, file); + Onyx.set(ONYXKEYS.VALIDATED_FILE_OBJECT, file); } /** diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index ebc3c97d19a34..3f52e268648e2 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -47,7 +47,7 @@ function ShareDetailsPage({ const {translate} = useLocalize(); const [unknownUserDetails] = useOnyx(ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS, {canBeMissing: true}); const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); - const [validFilesToUpload] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: true}); + const [validFilesToUpload] = useOnyx(ONYXKEYS.VALIDATED_FILE_OBJECT, {canBeMissing: true}); const validatedFile = validFilesToUpload?.at(0); const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index 5445c83193b51..23caa455c5d2b 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -50,7 +50,7 @@ function SubmitDetailsPage({ const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getIOURequestPolicyID(transaction, report)}`, {canBeMissing: false}); const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: false}); const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); - const [validFilesToUpload] = useOnyx(ONYXKEYS.SHARE_FILE_OBJECT, {canBeMissing: true}); + const [validFilesToUpload] = useOnyx(ONYXKEYS.VALIDATED_FILE_OBJECT, {canBeMissing: true}); const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); const shouldUsePreValidatedFile = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC; const validatedFile = validFilesToUpload?.at(0); From c338df1f1b54b1b4a563c4461be9b95d0735de0d Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Tue, 12 Aug 2025 15:45:16 +0200 Subject: [PATCH 07/13] fix es lint --- src/ONYXKEYS.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 410697b340985..30bc8a9d5f10f 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -1,6 +1,5 @@ import type {OnyxUpdate} from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; -import type {FileObject} from './components/AttachmentModal'; import type CONST from './CONST'; import type {OnboardingAccounting} from './CONST'; import type {OnboardingCompanySize} from './libs/actions/Welcome/OnboardingFlow'; From 1bd6fb5bf717934091110dffdc784eac89a0f916 Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Wed, 13 Aug 2025 13:49:38 +0200 Subject: [PATCH 08/13] changes after review --- src/CONST/index.ts | 2 ++ src/ONYXKEYS.ts | 2 +- src/libs/actions/Share.ts | 2 +- src/pages/Share/ShareDetailsPage.tsx | 5 ++--- src/pages/Share/ShareRootPage.tsx | 11 ++++++++--- src/pages/Share/SubmitDetailsPage.tsx | 7 +++---- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index ea6ae81763033..f774ac541d87e 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -1861,6 +1861,7 @@ const CONST = { MSWORD: 'application/msword', ZIP: 'application/zip', RFC822: 'message/rfc822', + HEIC: 'image/heic', }, SHARE_FILE_MIMETYPE: { @@ -1871,6 +1872,7 @@ const CONST = { WEBP: 'image/webp', TIF: 'image/tif', TIFF: 'image/tiff', + HEIC: 'image/heic', IMG: 'image/*', PDF: 'application/pdf', MSWORD: 'application/msword', diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 30bc8a9d5f10f..fa56a87bdf4ad 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -1199,7 +1199,7 @@ type OnyxValuesMapping = { [ONYXKEYS.CONCIERGE_REPORT_ID]: string; [ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS]: Participant; [ONYXKEYS.SHARE_TEMP_FILE]: OnyxTypes.ShareTempFile; - [ONYXKEYS.VALIDATED_FILE_OBJECT]: OnyxTypes.FileObject[]; + [ONYXKEYS.VALIDATED_FILE_OBJECT]: OnyxTypes.FileObject | undefined; [ONYXKEYS.CORPAY_FIELDS]: OnyxTypes.CorpayFields; [ONYXKEYS.PRESERVED_USER_SESSION]: OnyxTypes.Session; [ONYXKEYS.NVP_DISMISSED_PRODUCT_TRAINING]: OnyxTypes.DismissedProductTraining; diff --git a/src/libs/actions/Share.ts b/src/libs/actions/Share.ts index a499384556208..ee864931a6041 100644 --- a/src/libs/actions/Share.ts +++ b/src/libs/actions/Share.ts @@ -30,7 +30,7 @@ function addTempShareFile(file: ShareTempFile) { * @param file Array of validated file objects to be saved */ function addValidatedShareFile(file: FileObject[]) { - Onyx.set(ONYXKEYS.VALIDATED_FILE_OBJECT, file); + Onyx.set(ONYXKEYS.VALIDATED_FILE_OBJECT, file.at(0)); } /** diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index 3f52e268648e2..1565c2b641925 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -47,8 +47,7 @@ function ShareDetailsPage({ const {translate} = useLocalize(); const [unknownUserDetails] = useOnyx(ONYXKEYS.SHARE_UNKNOWN_USER_DETAILS, {canBeMissing: true}); const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); - const [validFilesToUpload] = useOnyx(ONYXKEYS.VALIDATED_FILE_OBJECT, {canBeMissing: true}); - const validatedFile = validFilesToUpload?.at(0); + const [validatedFile] = useOnyx(ONYXKEYS.VALIDATED_FILE_OBJECT, {canBeMissing: true}); const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); const isTextShared = currentAttachment?.mimeType === 'txt'; @@ -100,7 +99,7 @@ function ShareDetailsPage({ const fileName = currentAttachment?.content.split('/').pop(); const handleShare = () => { - if (!currentAttachment || (!!validFilesToUpload && validFilesToUpload.length === 0)) { + if (!currentAttachment || !!validatedFile) { return; } diff --git a/src/pages/Share/ShareRootPage.tsx b/src/pages/Share/ShareRootPage.tsx index cebc059c9cd31..5510b5025837b 100644 --- a/src/pages/Share/ShareRootPage.tsx +++ b/src/pages/Share/ShareRootPage.tsx @@ -41,8 +41,13 @@ function ShareRootPage() { const {validateFiles} = useFilesValidation(addValidatedShareFile); const isTextShared = currentAttachment?.mimeType === 'txt'; - const validateFilesWrapper = (file: ShareTempFile) => { - if (!file || isTextShared) { + // Currently, we use the pre-validated format only for HEIC files. If this changes, + // we need to ensure that in ShareDetailsPage and SubmitDetailsPage, + // the shouldUsePreValidatedFile condition is consistent with the one below. + const willNeedValidatedFiles = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC; + + const validateFileIfNecessary = (file: ShareTempFile) => { + if (!file || isTextShared || !willNeedValidatedFiles) { return; } @@ -121,7 +126,7 @@ function ShareRootPage() { } addTempShareFile(tempFile); - validateFilesWrapper(tempFile); + validateFileIfNecessary(tempFile); } }); }, [receiptFileFormats, shareFileMimeTypes, translate, errorTitle]); diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index edb55c7900002..0267ce287bec3 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -53,7 +53,6 @@ function SubmitDetailsPage({ const [validFilesToUpload] = useOnyx(ONYXKEYS.VALIDATED_FILE_OBJECT, {canBeMissing: true}); const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); const shouldUsePreValidatedFile = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC; - const validatedFile = validFilesToUpload?.at(0); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); @@ -64,9 +63,9 @@ function SubmitDetailsPage({ const {isBetaEnabled} = usePermissions(); const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS); - const fileUri = shouldUsePreValidatedFile ? (validatedFile?.uri ?? '') : (currentAttachment?.content ?? ''); - const fileName = shouldUsePreValidatedFile ? getFileName(validatedFile?.uri ?? 'shared_image.png') : getFileName(currentAttachment?.content ?? ''); - const fileType = shouldUsePreValidatedFile ? (validatedFile?.type ?? 'image/jpeg') : (currentAttachment?.mimeType ?? ''); + const fileUri = shouldUsePreValidatedFile ? (validFilesToUpload?.uri ?? '') : (currentAttachment?.content ?? ''); + const fileName = shouldUsePreValidatedFile ? getFileName(validFilesToUpload?.uri ?? 'shared_image.png') : getFileName(currentAttachment?.content ?? ''); + const fileType = shouldUsePreValidatedFile ? (validFilesToUpload?.type ?? 'image/jpeg') : (currentAttachment?.mimeType ?? ''); useEffect(() => { if (!errorTitle || !errorMessage) { From 14040ab7368d679332a095763c95f06c3f45d81f Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Wed, 13 Aug 2025 16:11:24 +0200 Subject: [PATCH 09/13] fix heic on native --- src/pages/Share/ShareDetailsPage.tsx | 12 ++++++------ src/pages/Share/ShareRootPage.tsx | 6 +++--- src/pages/Share/SubmitDetailsPage.tsx | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index 1565c2b641925..a47a4e2d1cfc3 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -51,7 +51,7 @@ function ShareDetailsPage({ const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); const isTextShared = currentAttachment?.mimeType === 'txt'; - const shouldUsePreValidatedFile = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC; + const shouldUsePreValidatedFile = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC || currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.IMG; const [message, setMessage] = useState(isTextShared ? (currentAttachment?.content ?? '') : ''); const [errorTitle, setErrorTitle] = useState(undefined); const [errorMessage, setErrorMessage] = useState(undefined); @@ -96,10 +96,8 @@ function ShareDetailsPage({ const currentUserID = getCurrentUserAccountID(); const shouldShowAttachment = !isTextShared; - const fileName = currentAttachment?.content.split('/').pop(); - const handleShare = () => { - if (!currentAttachment || !!validatedFile) { + if (!currentAttachment || !validatedFile) { return; } @@ -137,6 +135,8 @@ function ShareDetailsPage({ ); }; + debugger; + return ( {({show}) => ( diff --git a/src/pages/Share/ShareRootPage.tsx b/src/pages/Share/ShareRootPage.tsx index 5510b5025837b..465f286ddf8e2 100644 --- a/src/pages/Share/ShareRootPage.tsx +++ b/src/pages/Share/ShareRootPage.tsx @@ -41,10 +41,10 @@ function ShareRootPage() { const {validateFiles} = useFilesValidation(addValidatedShareFile); const isTextShared = currentAttachment?.mimeType === 'txt'; - // Currently, we use the pre-validated format only for HEIC files. If this changes, + // Currently, we use the pre-validated format for HEIC/other IMG files. If this changes, // we need to ensure that in ShareDetailsPage and SubmitDetailsPage, // the shouldUsePreValidatedFile condition is consistent with the one below. - const willNeedValidatedFiles = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC; + const willNeedValidatedFiles = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC || currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.IMG; const validateFileIfNecessary = (file: ShareTempFile) => { if (!file || isTextShared || !willNeedValidatedFiles) { @@ -122,11 +122,11 @@ function ShareRootPage() { } else { setIsFileScannable(false); } + validateFileIfNecessary(tempFile); setIsFileReady(true); } addTempShareFile(tempFile); - validateFileIfNecessary(tempFile); } }); }, [receiptFileFormats, shareFileMimeTypes, translate, errorTitle]); diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index 0267ce287bec3..8a848903a6bd7 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -52,7 +52,7 @@ function SubmitDetailsPage({ const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); const [validFilesToUpload] = useOnyx(ONYXKEYS.VALIDATED_FILE_OBJECT, {canBeMissing: true}); const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); - const shouldUsePreValidatedFile = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC; + const shouldUsePreValidatedFile = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC || currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.IMG; const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); From 86757517454170ba04311ee24bc63dd04129cbf1 Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Wed, 13 Aug 2025 16:15:31 +0200 Subject: [PATCH 10/13] remove debugger --- src/pages/Share/ShareDetailsPage.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index a47a4e2d1cfc3..374b1969f13ea 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -135,8 +135,6 @@ function ShareDetailsPage({ ); }; - debugger; - return ( Date: Thu, 14 Aug 2025 14:54:53 +0200 Subject: [PATCH 11/13] changes after code review --- src/CONST/index.ts | 2 +- src/libs/ReceiptUtils.ts | 8 ++++++-- src/pages/Share/ShareDetailsPage.tsx | 11 ++++++----- src/pages/Share/ShareRootPage.tsx | 8 ++------ src/pages/Share/SubmitDetailsPage.tsx | 7 ++++--- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index f774ac541d87e..aa2da1c450f76 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -1822,7 +1822,7 @@ const CONST = { ATTACHMENT_THUMBNAIL_WIDTH_ATTRIBUTE: 'data-expensify-width', ATTACHMENT_THUMBNAIL_HEIGHT_ATTRIBUTE: 'data-expensify-height', ATTACHMENT_DURATION_ATTRIBUTE: 'data-expensify-duration', - + ATTACHMENT_IMAGE_DEFAULT_NAME: 'shared_image.png', ATTACHMENT_PICKER_TYPE: { FILE: 'file', IMAGE: 'image', diff --git a/src/libs/ReceiptUtils.ts b/src/libs/ReceiptUtils.ts index 5085f0e2384e2..82bec0b9d8219 100644 --- a/src/libs/ReceiptUtils.ts +++ b/src/libs/ReceiptUtils.ts @@ -3,7 +3,7 @@ import findLast from 'lodash/findLast'; import type {OnyxEntry} from 'react-native-onyx'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; -import type {Transaction} from '@src/types/onyx'; +import type {ShareTempFile, Transaction} from '@src/types/onyx'; import type {ReceiptError, ReceiptSource} from '@src/types/onyx/Transaction'; import * as FileUtils from './fileDownload/FileUtils'; import * as TransactionUtils from './TransactionUtils'; @@ -65,6 +65,10 @@ function getThumbnailAndImageURIs(transaction: OnyxEntry, receiptPa return {isThumbnail: true, fileExtension: Object.values(CONST.IOU.FILE_TYPES).find((type) => type === fileExtension), image: path, isLocalFile, filename}; } +const checkNesesarityOfFileValidation = (file: ShareTempFile | undefined) => { + return file?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC || file?.mimeType === CONST.SHARE_FILE_MIMETYPE.IMG; +}; + // eslint-disable-next-line import/prefer-default-export -export {getThumbnailAndImageURIs}; +export {getThumbnailAndImageURIs, checkNesesarityOfFileValidation}; export type {ThumbnailAndImageURI}; diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index 374b1969f13ea..a5cba20e52343 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -22,6 +22,7 @@ import {getFileName, readFileAsync} from '@libs/fileDownload/FileUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {ShareNavigatorParamList} from '@libs/Navigation/types'; import {getReportDisplayOption} from '@libs/OptionsListUtils'; +import {checkNesesarityOfFileValidation} from '@libs/ReceiptUtils'; import {getReportOrDraftReport, isDraftReport} from '@libs/ReportUtils'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; import variables from '@styles/variables'; @@ -50,8 +51,8 @@ function ShareDetailsPage({ const [validatedFile] = useOnyx(ONYXKEYS.VALIDATED_FILE_OBJECT, {canBeMissing: true}); const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); - const isTextShared = currentAttachment?.mimeType === 'txt'; - const shouldUsePreValidatedFile = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC || currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.IMG; + const isTextShared = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.TXT; + const shouldUsePreValidatedFile = checkNesesarityOfFileValidation(currentAttachment); const [message, setMessage] = useState(isTextShared ? (currentAttachment?.content ?? '') : ''); const [errorTitle, setErrorTitle] = useState(undefined); const [errorMessage, setErrorMessage] = useState(undefined); @@ -60,8 +61,8 @@ function ShareDetailsPage({ const displayReport = useMemo(() => getReportDisplayOption(report, unknownUserDetails, reportAttributesDerived), [report, unknownUserDetails, reportAttributesDerived]); const fileUri = shouldUsePreValidatedFile ? (validatedFile?.uri ?? '') : (currentAttachment?.content ?? ''); - const validateFileName = shouldUsePreValidatedFile ? getFileName(validatedFile?.uri ?? 'shared_image.png') : getFileName(currentAttachment?.content ?? ''); - const fileType = shouldUsePreValidatedFile ? (validatedFile?.type ?? 'image/jpeg') : (currentAttachment?.mimeType ?? ''); + const validateFileName = shouldUsePreValidatedFile ? getFileName(validatedFile?.uri ?? CONST.ATTACHMENT_IMAGE_DEFAULT_NAME) : getFileName(currentAttachment?.content ?? ''); + const fileType = shouldUsePreValidatedFile ? (validatedFile?.type ?? CONST.SHARE_FILE_MIMETYPE.JPEG) : (currentAttachment?.mimeType ?? ''); useEffect(() => { if (!currentAttachment?.content || errorTitle) { @@ -97,7 +98,7 @@ function ShareDetailsPage({ const shouldShowAttachment = !isTextShared; const handleShare = () => { - if (!currentAttachment || !validatedFile) { + if (!currentAttachment || (shouldUsePreValidatedFile && !validatedFile)) { return; } diff --git a/src/pages/Share/ShareRootPage.tsx b/src/pages/Share/ShareRootPage.tsx index 465f286ddf8e2..e7f3e022dd413 100644 --- a/src/pages/Share/ShareRootPage.tsx +++ b/src/pages/Share/ShareRootPage.tsx @@ -14,6 +14,7 @@ import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import {splitExtensionFromFileName, validateImageForCorruption} from '@libs/fileDownload/FileUtils'; import Navigation from '@libs/Navigation/Navigation'; import OnyxTabNavigator, {TopTab} from '@libs/Navigation/OnyxTabNavigator'; +import {checkNesesarityOfFileValidation} from '@libs/ReceiptUtils'; import ShareActionHandler from '@libs/ShareActionHandlerModule'; import type {FileObject} from '@pages/media/AttachmentModalScreen/types'; import CONST from '@src/CONST'; @@ -41,13 +42,8 @@ function ShareRootPage() { const {validateFiles} = useFilesValidation(addValidatedShareFile); const isTextShared = currentAttachment?.mimeType === 'txt'; - // Currently, we use the pre-validated format for HEIC/other IMG files. If this changes, - // we need to ensure that in ShareDetailsPage and SubmitDetailsPage, - // the shouldUsePreValidatedFile condition is consistent with the one below. - const willNeedValidatedFiles = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC || currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.IMG; - const validateFileIfNecessary = (file: ShareTempFile) => { - if (!file || isTextShared || !willNeedValidatedFiles) { + if (!file || isTextShared || !checkNesesarityOfFileValidation(file)) { return; } diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index 8a848903a6bd7..344d71ecea645 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -22,6 +22,7 @@ import navigateAfterInteraction from '@libs/Navigation/navigateAfterInteraction' import Navigation from '@libs/Navigation/Navigation'; import type {ShareNavigatorParamList} from '@libs/Navigation/types'; import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils'; +import {checkNesesarityOfFileValidation} from '@libs/ReceiptUtils'; import {getReportOrDraftReport, isSelfDM} from '@libs/ReportUtils'; import {getDefaultTaxCode} from '@libs/TransactionUtils'; import CONST from '@src/CONST'; @@ -52,7 +53,7 @@ function SubmitDetailsPage({ const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); const [validFilesToUpload] = useOnyx(ONYXKEYS.VALIDATED_FILE_OBJECT, {canBeMissing: true}); const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); - const shouldUsePreValidatedFile = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC || currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.IMG; + const shouldUsePreValidatedFile = checkNesesarityOfFileValidation(currentAttachment); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); @@ -64,8 +65,8 @@ function SubmitDetailsPage({ const shouldGenerateTransactionThreadReport = !isBetaEnabled(CONST.BETAS.NO_OPTIMISTIC_TRANSACTION_THREADS); const fileUri = shouldUsePreValidatedFile ? (validFilesToUpload?.uri ?? '') : (currentAttachment?.content ?? ''); - const fileName = shouldUsePreValidatedFile ? getFileName(validFilesToUpload?.uri ?? 'shared_image.png') : getFileName(currentAttachment?.content ?? ''); - const fileType = shouldUsePreValidatedFile ? (validFilesToUpload?.type ?? 'image/jpeg') : (currentAttachment?.mimeType ?? ''); + const fileName = shouldUsePreValidatedFile ? getFileName(validFilesToUpload?.uri ?? CONST.ATTACHMENT_IMAGE_DEFAULT_NAME) : getFileName(currentAttachment?.content ?? ''); + const fileType = shouldUsePreValidatedFile ? (validFilesToUpload?.type ?? CONST.RECEIPT_ALLOWED_FILE_TYPES.JPEG) : (currentAttachment?.mimeType ?? ''); useEffect(() => { if (!errorTitle || !errorMessage) { From 3b121dd1dcb7b4a004a1e5ea3897358de9d8d04f Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Thu, 14 Aug 2025 20:49:52 +0200 Subject: [PATCH 12/13] eslint, spelling fixes --- src/libs/ReceiptUtils.ts | 18 +++++++++--------- src/pages/Share/ShareDetailsPage.tsx | 4 ++-- src/pages/Share/ShareRootPage.tsx | 4 ++-- src/pages/Share/SubmitDetailsPage.tsx | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libs/ReceiptUtils.ts b/src/libs/ReceiptUtils.ts index 82bec0b9d8219..e611e4bfebf93 100644 --- a/src/libs/ReceiptUtils.ts +++ b/src/libs/ReceiptUtils.ts @@ -5,8 +5,8 @@ import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import type {ShareTempFile, Transaction} from '@src/types/onyx'; import type {ReceiptError, ReceiptSource} from '@src/types/onyx/Transaction'; -import * as FileUtils from './fileDownload/FileUtils'; -import * as TransactionUtils from './TransactionUtils'; +import {isLocalFile as isLocalFileUtils, splitExtensionFromFileName} from './fileDownload/FileUtils'; +import {hasReceipt, hasReceiptSource, isFetchingWaypointsFromServer} from './TransactionUtils'; type ThumbnailAndImageURI = { image?: string; @@ -27,10 +27,10 @@ type ThumbnailAndImageURI = { * @param receiptFileName */ function getThumbnailAndImageURIs(transaction: OnyxEntry, receiptPath: ReceiptSource | null = null, receiptFileName: string | null = null): ThumbnailAndImageURI { - if (!TransactionUtils.hasReceipt(transaction) && !receiptPath && !receiptFileName) { + if (!hasReceipt(transaction) && !receiptPath && !receiptFileName) { return {isEmptyReceipt: true}; } - if (TransactionUtils.isFetchingWaypointsFromServer(transaction)) { + if (isFetchingWaypointsFromServer(transaction)) { return {isThumbnail: true, isLocalFile: true}; } // If there're errors, we need to display them in preview. We can store many files in errors, but we just need to get the last one @@ -40,7 +40,7 @@ function getThumbnailAndImageURIs(transaction: OnyxEntry, receiptPa // filename of uploaded image or last part of remote URI const filename = errors?.filename ?? transaction?.filename ?? receiptFileName ?? ''; const isReceiptImage = Str.isImage(filename); - const hasEReceipt = !TransactionUtils.hasReceiptSource(transaction) && transaction?.hasEReceipt; + const hasEReceipt = !hasReceiptSource(transaction) && transaction?.hasEReceipt; const isReceiptPDF = Str.isPDF(filename); if (hasEReceipt) { @@ -60,15 +60,15 @@ function getThumbnailAndImageURIs(transaction: OnyxEntry, receiptPa return {thumbnail: `${path.substring(0, path.length - 4)}.jpg.1024.jpg`, image: path, filename}; } - const isLocalFile = FileUtils.isLocalFile(path); - const {fileExtension} = FileUtils.splitExtensionFromFileName(filename); + const isLocalFile = isLocalFileUtils(path); + const {fileExtension} = splitExtensionFromFileName(filename); return {isThumbnail: true, fileExtension: Object.values(CONST.IOU.FILE_TYPES).find((type) => type === fileExtension), image: path, isLocalFile, filename}; } -const checkNesesarityOfFileValidation = (file: ShareTempFile | undefined) => { +const shouldValidateFile = (file: ShareTempFile | undefined) => { return file?.mimeType === CONST.SHARE_FILE_MIMETYPE.HEIC || file?.mimeType === CONST.SHARE_FILE_MIMETYPE.IMG; }; // eslint-disable-next-line import/prefer-default-export -export {getThumbnailAndImageURIs, checkNesesarityOfFileValidation}; +export {getThumbnailAndImageURIs, shouldValidateFile}; export type {ThumbnailAndImageURI}; diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index a5cba20e52343..11accbe2f737a 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -22,7 +22,7 @@ import {getFileName, readFileAsync} from '@libs/fileDownload/FileUtils'; import Navigation from '@libs/Navigation/Navigation'; import type {ShareNavigatorParamList} from '@libs/Navigation/types'; import {getReportDisplayOption} from '@libs/OptionsListUtils'; -import {checkNesesarityOfFileValidation} from '@libs/ReceiptUtils'; +import {shouldValidateFile} from '@libs/ReceiptUtils'; import {getReportOrDraftReport, isDraftReport} from '@libs/ReportUtils'; import NotFoundPage from '@pages/ErrorPage/NotFoundPage'; import variables from '@styles/variables'; @@ -52,7 +52,7 @@ function ShareDetailsPage({ const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); const isTextShared = currentAttachment?.mimeType === CONST.SHARE_FILE_MIMETYPE.TXT; - const shouldUsePreValidatedFile = checkNesesarityOfFileValidation(currentAttachment); + const shouldUsePreValidatedFile = shouldValidateFile(currentAttachment); const [message, setMessage] = useState(isTextShared ? (currentAttachment?.content ?? '') : ''); const [errorTitle, setErrorTitle] = useState(undefined); const [errorMessage, setErrorMessage] = useState(undefined); diff --git a/src/pages/Share/ShareRootPage.tsx b/src/pages/Share/ShareRootPage.tsx index e7f3e022dd413..1d95e22300cac 100644 --- a/src/pages/Share/ShareRootPage.tsx +++ b/src/pages/Share/ShareRootPage.tsx @@ -14,7 +14,7 @@ import {canUseTouchScreen} from '@libs/DeviceCapabilities'; import {splitExtensionFromFileName, validateImageForCorruption} from '@libs/fileDownload/FileUtils'; import Navigation from '@libs/Navigation/Navigation'; import OnyxTabNavigator, {TopTab} from '@libs/Navigation/OnyxTabNavigator'; -import {checkNesesarityOfFileValidation} from '@libs/ReceiptUtils'; +import {shouldValidateFile} from '@libs/ReceiptUtils'; import ShareActionHandler from '@libs/ShareActionHandlerModule'; import type {FileObject} from '@pages/media/AttachmentModalScreen/types'; import CONST from '@src/CONST'; @@ -43,7 +43,7 @@ function ShareRootPage() { const isTextShared = currentAttachment?.mimeType === 'txt'; const validateFileIfNecessary = (file: ShareTempFile) => { - if (!file || isTextShared || !checkNesesarityOfFileValidation(file)) { + if (!file || isTextShared || !shouldValidateFile(file)) { return; } diff --git a/src/pages/Share/SubmitDetailsPage.tsx b/src/pages/Share/SubmitDetailsPage.tsx index 344d71ecea645..959ab18586ad6 100644 --- a/src/pages/Share/SubmitDetailsPage.tsx +++ b/src/pages/Share/SubmitDetailsPage.tsx @@ -22,7 +22,7 @@ import navigateAfterInteraction from '@libs/Navigation/navigateAfterInteraction' import Navigation from '@libs/Navigation/Navigation'; import type {ShareNavigatorParamList} from '@libs/Navigation/types'; import {getParticipantsOption, getReportOption} from '@libs/OptionsListUtils'; -import {checkNesesarityOfFileValidation} from '@libs/ReceiptUtils'; +import {shouldValidateFile} from '@libs/ReceiptUtils'; import {getReportOrDraftReport, isSelfDM} from '@libs/ReportUtils'; import {getDefaultTaxCode} from '@libs/TransactionUtils'; import CONST from '@src/CONST'; @@ -53,7 +53,7 @@ function SubmitDetailsPage({ const [reportAttributesDerived] = useOnyx(ONYXKEYS.DERIVED.REPORT_ATTRIBUTES, {canBeMissing: true, selector: (val) => val?.reports}); const [validFilesToUpload] = useOnyx(ONYXKEYS.VALIDATED_FILE_OBJECT, {canBeMissing: true}); const [currentAttachment] = useOnyx(ONYXKEYS.SHARE_TEMP_FILE, {canBeMissing: true}); - const shouldUsePreValidatedFile = checkNesesarityOfFileValidation(currentAttachment); + const shouldUsePreValidatedFile = shouldValidateFile(currentAttachment); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); From 01a0cee0e0811daaf1f6d35f4b686a97d8bf2c3f Mon Sep 17 00:00:00 2001 From: sumo_slonik Date: Tue, 19 Aug 2025 12:06:08 +0200 Subject: [PATCH 13/13] rename variable --- src/pages/Share/ShareDetailsPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/Share/ShareDetailsPage.tsx b/src/pages/Share/ShareDetailsPage.tsx index 11accbe2f737a..4fe355e399631 100644 --- a/src/pages/Share/ShareDetailsPage.tsx +++ b/src/pages/Share/ShareDetailsPage.tsx @@ -60,7 +60,7 @@ function ShareDetailsPage({ const report: OnyxEntry = getReportOrDraftReport(reportOrAccountID); const displayReport = useMemo(() => getReportDisplayOption(report, unknownUserDetails, reportAttributesDerived), [report, unknownUserDetails, reportAttributesDerived]); - const fileUri = shouldUsePreValidatedFile ? (validatedFile?.uri ?? '') : (currentAttachment?.content ?? ''); + const fileSource = shouldUsePreValidatedFile ? (validatedFile?.uri ?? '') : (currentAttachment?.content ?? ''); const validateFileName = shouldUsePreValidatedFile ? getFileName(validatedFile?.uri ?? CONST.ATTACHMENT_IMAGE_DEFAULT_NAME) : getFileName(currentAttachment?.content ?? ''); const fileType = shouldUsePreValidatedFile ? (validatedFile?.type ?? CONST.SHARE_FILE_MIMETYPE.JPEG) : (currentAttachment?.mimeType ?? ''); @@ -110,7 +110,7 @@ function ShareDetailsPage({ } readFileAsync( - fileUri, + fileSource, validateFileName, (file) => { if (isDraft) { @@ -203,13 +203,13 @@ function ShareDetailsPage({ {({show}) => ( {