diff --git a/src/components/PaymentRequest/MakeExpense.jsx b/src/components/PaymentRequest/MakeExpense.jsx index c4264fa4..9401a055 100644 --- a/src/components/PaymentRequest/MakeExpense.jsx +++ b/src/components/PaymentRequest/MakeExpense.jsx @@ -32,7 +32,7 @@ const MakeExpense = ({ onClose }) => { const files = watch("billAttachments"); const onFileChange = async (e) => { const newFiles = Array.from(e.target.files); - if (newFiles.length === 0) return; + if (newFiles?.length === 0) return; const existingFiles = watch("billAttachments") || []; @@ -199,7 +199,7 @@ const MakeExpense = ({ onClose }) => { {errors.billAttachments.message} )} - {files.length > 0 && ( + {files?.length > 0 && ( { const newFiles = Array.from(e.target.files); - if (newFiles.length === 0) return; + if (newFiles?.length === 0) return; const existingFiles = watch("billAttachments") || []; const parsedFiles = await Promise.all( - newFiles.map(async (file) => { + newFiles?.map(async (file) => { const base64Data = await toBase64(file); return { fileName: file.name, @@ -175,7 +175,7 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) { }, [data, reset]); useEffect(() => { - if (!requestToEdit && currencyData && currencyData.length > 0) { + if (!requestToEdit && currencyData && currencyData?.length > 0) { const inrCurrency = currencyData.find((c) => c.id === INR_CURRENCY_CODE); if (inrCurrency) { setValue("currencyId", INR_CURRENCY_CODE, { shouldValidate: true }); @@ -480,7 +480,7 @@ function ManagePaymentRequest({ closeModal, requestToEdit = null }) { {errors.billAttachments.message} )} - {files.length > 0 && ( + {files?.length > 0 && ( { ? status.permissionIds : []; - if (permissionIds.length === 0) return true; + if (permissionIds?.length === 0) return true; if (permissionIds.includes(PROCESS_EXPENSE)) { setIsPaymentProcess(true); } @@ -393,7 +393,7 @@ const ViewPaymentRequest = ({ requestId }) => { )} - {Array.isArray(data?.nextStatus) && data?.nextStatus.length > 0 ? ( + {Array.isArray(data?.nextStatus) && data?.nextStatus?.length > 0 ? ( <> {IsPaymentProcess && nextStatusWithPermission?.length > 0 && (
@@ -478,7 +478,7 @@ const ViewPaymentRequest = ({ requestId }) => {
)}
- {((nextStatusWithPermission.length > 0 && + {((nextStatusWithPermission?.length > 0 && !isRejectedRequest) || (isRejectedRequest && isCreatedBy)) && ( <>