From 4ae5bbbbae6bbbb7504177b84f284d32145c2706 Mon Sep 17 00:00:00 2001 From: I Nyoman Jyotisa Date: Thu, 13 Nov 2025 08:25:54 +0800 Subject: [PATCH 1/2] Fix: Prevent saving empty date on expense --- .../iou/request/step/IOURequestStepDate.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDate.tsx b/src/pages/iou/request/step/IOURequestStepDate.tsx index feaae65ae4a2..76cbc5300276 100644 --- a/src/pages/iou/request/step/IOURequestStepDate.tsx +++ b/src/pages/iou/request/step/IOURequestStepDate.tsx @@ -1,10 +1,10 @@ import lodashIsEmpty from 'lodash/isEmpty'; -import React from 'react'; +import React, {useCallback} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import DatePicker from '@components/DatePicker'; import FormProvider from '@components/Form/FormProvider'; import InputWrapper from '@components/Form/InputWrapper'; -import type {FormOnyxValues} from '@components/Form/types'; +import type {FormInputErrors, FormOnyxValues} from '@components/Form/types'; import useDuplicateTransactionsAndViolations from '@hooks/useDuplicateTransactionsAndViolations'; import useLocalize from '@hooks/useLocalize'; import useOnyx from '@hooks/useOnyx'; @@ -91,6 +91,17 @@ function IOURequestStepDate({ navigateBack(); }; + const validate = useCallback( + (values: FormOnyxValues) => { + const errors: FormInputErrors = {}; + if (!values.moneyRequestCreated || values.moneyRequestCreated === '') { + errors.moneyRequestCreated = translate('common.error.fieldRequired'); + } + return errors; + }, + [translate], + ); + return ( Date: Thu, 20 Nov 2025 09:00:49 +0800 Subject: [PATCH 2/2] minor fix --- src/pages/iou/request/step/IOURequestStepDate.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/iou/request/step/IOURequestStepDate.tsx b/src/pages/iou/request/step/IOURequestStepDate.tsx index 76cbc5300276..2b2e68df76e9 100644 --- a/src/pages/iou/request/step/IOURequestStepDate.tsx +++ b/src/pages/iou/request/step/IOURequestStepDate.tsx @@ -94,8 +94,8 @@ function IOURequestStepDate({ const validate = useCallback( (values: FormOnyxValues) => { const errors: FormInputErrors = {}; - if (!values.moneyRequestCreated || values.moneyRequestCreated === '') { - errors.moneyRequestCreated = translate('common.error.fieldRequired'); + if (!values[INPUT_IDS.MONEY_REQUEST_CREATED] || values[INPUT_IDS.MONEY_REQUEST_CREATED] === '') { + errors[INPUT_IDS.MONEY_REQUEST_CREATED] = translate('common.error.fieldRequired'); } return errors; },