From fc8ea24e8d78f35ddcafd6416c1483f8ca50cc35 Mon Sep 17 00:00:00 2001 From: Vivek Kumar <35863227+techievivek@users.noreply.github.com> Date: Wed, 1 Jan 2025 20:12:38 +0530 Subject: [PATCH] Merge pull request #54719 from Expensify/revert-53902-update-translation-key Revert "Fix unable to upload a receipt size larger than 15mb" (cherry picked from commit 576194df3fc2e79895dbbd67fb02b875e71a7afc) (CP triggered by Beamanator) --- src/languages/en.ts | 1 - src/languages/es.ts | 1 - src/libs/ReportUtils.ts | 4 ++-- src/pages/home/HeaderView.tsx | 10 ++++---- .../step/IOURequestStepScan/index.native.tsx | 15 +++++------- .../request/step/IOURequestStepScan/index.tsx | 24 ++++++------------- 6 files changed, 19 insertions(+), 36 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 7dfd0511b1a1..a7723c8b9d39 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -517,7 +517,6 @@ const translations = { chooseDocument: 'Choose file', attachmentTooLarge: 'Attachment is too large', sizeExceeded: 'Attachment size is larger than 24 MB limit', - sizeExceededWithLimit: ({maxUploadSizeInMB}: SizeExceededParams) => `Attachment size is larger than ${maxUploadSizeInMB} MB limit`, attachmentTooSmall: 'Attachment is too small', sizeNotMet: 'Attachment size must be greater than 240 bytes', wrongFileType: 'Invalid file type', diff --git a/src/languages/es.ts b/src/languages/es.ts index 2638a3450674..01c50ff8b24c 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -512,7 +512,6 @@ const translations = { chooseDocument: 'Elegir un archivo', attachmentTooLarge: 'Archivo adjunto demasiado grande', sizeExceeded: 'El archivo adjunto supera el límite de 24 MB.', - sizeExceededWithLimit: ({maxUploadSizeInMB}: SizeExceededParams) => `El archivo adjunto supera el límite de ${maxUploadSizeInMB} MB.`, attachmentTooSmall: 'Archivo adjunto demasiado pequeño', sizeNotMet: 'El archivo adjunto debe ser más grande que 240 bytes.', wrongFileType: 'Tipo de archivo inválido', diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 82aebd044a8f..589c5f1a6adc 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -1051,8 +1051,8 @@ function isSettled(reportOrID: OnyxInputOrEntry | SearchReport | string /** * Whether the current user is the submitter of the report */ -function isCurrentUserSubmitter(reportID: string | undefined): boolean { - if (!allReports || !reportID) { +function isCurrentUserSubmitter(reportID: string): boolean { + if (!allReports) { return false; } const report = allReports[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; diff --git a/src/pages/home/HeaderView.tsx b/src/pages/home/HeaderView.tsx index 8f1933b076f0..cf7e2adfccd0 100644 --- a/src/pages/home/HeaderView.tsx +++ b/src/pages/home/HeaderView.tsx @@ -70,11 +70,9 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto const {isSmallScreenWidth} = useResponsiveLayout(); const route = useRoute(); const [isDeleteTaskConfirmModalVisible, setIsDeleteTaskConfirmModalVisible] = React.useState(false); - const [invoiceReceiverPolicy] = useOnyx( - `${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : CONST.DEFAULT_NUMBER_ID}`, - ); + const [invoiceReceiverPolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${report?.invoiceReceiver && 'policyID' in report.invoiceReceiver ? report.invoiceReceiver.policyID : -1}`); // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || report?.reportID}`); + const [parentReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${report?.parentReportID || report?.reportID || '-1'}`); const policy = usePolicy(report?.policyID); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); @@ -102,7 +100,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto const reportDescription = Parser.htmlToText(ReportUtils.getReportDescription(report)); const policyName = ReportUtils.getPolicyName(report, true); const policyDescription = ReportUtils.getPolicyDescriptionText(policy); - const isPersonalExpenseChat = isPolicyExpenseChat && ReportUtils.isCurrentUserSubmitter(report?.reportID); + const isPersonalExpenseChat = isPolicyExpenseChat && ReportUtils.isCurrentUserSubmitter(report?.reportID ?? ''); const shouldShowSubtitle = () => { if (!subtitle) { return false; @@ -260,7 +258,7 @@ function HeaderView({report, parentReportAction, reportID, onNavigationMenuButto { if (ReportUtils.canEditPolicyDescription(policy)) { - Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(`${report.policyID ?? CONST.DEFAULT_NUMBER_ID}`)); + Navigation.navigate(ROUTES.WORKSPACE_PROFILE_DESCRIPTION.getRoute(report.policyID ?? '-1')); return; } Navigation.navigate(ROUTES.REPORT_WITH_ID_DETAILS.getRoute(reportID, Navigation.getReportRHPActiveRoute())); diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx index e76d3554e864..127885289fb1 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.native.tsx @@ -74,10 +74,10 @@ function IOURequestStepScan({ const [startLocationPermissionFlow, setStartLocationPermissionFlow] = useState(false); const [fileResize, setFileResize] = useState(null); const [fileSource, setFileSource] = useState(''); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? CONST.DEFAULT_NUMBER_ID}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const policy = usePolicy(report?.policyID); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); - const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID ?? CONST.DEFAULT_NUMBER_ID}`); + const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID ?? -1}`); const platform = getPlatform(true); const [mutedPlatforms = {}] = useOnyx(ONYXKEYS.NVP_MUTED_PLATFORMS); const isPlatformMuted = mutedPlatforms[platform]; @@ -198,10 +198,7 @@ function IOURequestStepScan({ } if (!Str.isImage(file.name ?? '') && (file?.size ?? 0) > CONST.API_ATTACHMENT_VALIDATIONS.RECEIPT_MAX_SIZE) { - Alert.alert( - translate('attachmentPicker.attachmentTooLarge'), - translate('attachmentPicker.sizeExceededWithLimit', {maxUploadSizeInMB: CONST.API_ATTACHMENT_VALIDATIONS.RECEIPT_MAX_SIZE / (1024 * 1024)}), - ); + Alert.alert(translate('attachmentPicker.attachmentTooLarge'), translate('attachmentPicker.sizeExceeded')); return false; } @@ -298,7 +295,7 @@ function IOURequestStepScan({ // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { - const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; + const participantAccountID = participant?.accountID ?? -1; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); @@ -311,10 +308,10 @@ function IOURequestStepScan({ IOU.startSplitBill({ participants, currentUserLogin: currentUserPersonalDetails?.login ?? '', - currentUserAccountID: currentUserPersonalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID, + currentUserAccountID: currentUserPersonalDetails?.accountID ?? -1, comment: '', receipt, - existingSplitChatReportID: reportID ?? CONST.DEFAULT_NUMBER_ID, + existingSplitChatReportID: reportID ?? -1, billable: false, category: '', tag: '', diff --git a/src/pages/iou/request/step/IOURequestStepScan/index.tsx b/src/pages/iou/request/step/IOURequestStepScan/index.tsx index 002b0c8ed57a..b2d9fd5e78b1 100644 --- a/src/pages/iou/request/step/IOURequestStepScan/index.tsx +++ b/src/pages/iou/request/step/IOURequestStepScan/index.tsx @@ -86,10 +86,10 @@ function IOURequestStepScan({ const [isQueriedPermissionState, setIsQueriedPermissionState] = useState(false); const getScreenshotTimeoutRef = useRef(null); - const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? CONST.DEFAULT_NUMBER_ID}`); + const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report?.reportID ?? -1}`); const policy = usePolicy(report?.policyID); const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST); - const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID ?? CONST.DEFAULT_NUMBER_ID}`); + const [skipConfirmation] = useOnyx(`${ONYXKEYS.COLLECTION.SKIP_CONFIRMATION}${transactionID ?? -1}`); const [isLoadingReceipt, setIsLoadingReceipt] = useState(false); const [videoConstraints, setVideoConstraints] = useState(); @@ -221,7 +221,7 @@ function IOURequestStepScan({ } if (!Str.isImage(file.name ?? '') && (file?.size ?? 0) > CONST.API_ATTACHMENT_VALIDATIONS.RECEIPT_MAX_SIZE) { - setUploadReceiptError(true, 'attachmentPicker.attachmentTooLarge', 'attachmentPicker.sizeExceededWithLimit'); + setUploadReceiptError(true, 'attachmentPicker.attachmentTooLarge', 'attachmentPicker.sizeExceeded'); return false; } @@ -324,7 +324,7 @@ function IOURequestStepScan({ // be added to the transaction (taken from the chat report participants) and then the person is taken to the confirmation step. const selectedParticipants = IOU.setMoneyRequestParticipantsFromReport(transactionID, report); const participants = selectedParticipants.map((participant) => { - const participantAccountID = participant?.accountID ?? CONST.DEFAULT_NUMBER_ID; + const participantAccountID = participant?.accountID ?? -1; return participantAccountID ? OptionsListUtils.getParticipantsOption(participant, personalDetails) : OptionsListUtils.getReportOption(participant); }); @@ -337,10 +337,10 @@ function IOURequestStepScan({ IOU.startSplitBill({ participants, currentUserLogin: currentUserPersonalDetails?.login ?? '', - currentUserAccountID: currentUserPersonalDetails?.accountID ?? CONST.DEFAULT_NUMBER_ID, + currentUserAccountID: currentUserPersonalDetails?.accountID ?? -1, comment: '', receipt, - existingSplitChatReportID: reportID ?? CONST.DEFAULT_NUMBER_ID, + existingSplitChatReportID: reportID ?? -1, billable: false, category: '', tag: '', @@ -618,16 +618,6 @@ function IOURequestStepScan({ /> ) : null; - const getConfirmModalPrompt = () => { - if (!attachmentInvalidReason) { - return ''; - } - if (attachmentInvalidReason === 'attachmentPicker.sizeExceededWithLimit') { - return translate(attachmentInvalidReason, {maxUploadSizeInMB: CONST.API_ATTACHMENT_VALIDATIONS.RECEIPT_MAX_SIZE / (1024 * 1024)}); - } - return translate(attachmentInvalidReason); - }; - const mobileCameraView = () => ( <> @@ -804,7 +794,7 @@ function IOURequestStepScan({ onConfirm={hideRecieptModal} onCancel={hideRecieptModal} isVisible={isAttachmentInvalid} - prompt={getConfirmModalPrompt()} + prompt={attachmentInvalidReason ? translate(attachmentInvalidReason) : ''} confirmText={translate('common.close')} shouldShowCancelButton={false} />