@@ -97,6 +97,8 @@ const baseParams = {
9797 isTimeRequest : false ,
9898 routeError : undefined ,
9999 isNewManualExpenseFlowEnabled : false ,
100+ isReadOnly : false ,
101+ shouldShowDate : true ,
100102} satisfies UseConfirmationValidationParams ;
101103
102104function createValidationParamsForParticipant (
@@ -746,4 +748,95 @@ describe('useConfirmationValidation', () => {
746748 expect ( result . current . validate ( ) ) . toEqual ( { errorKey : 'iou.error.invalidAmount' } ) ;
747749 } ) ;
748750 } ) ;
751+
752+ describe ( 'date validation — inline required date in new manual expense flow' , ( ) => {
753+ const newManualFlowParams = {
754+ ...baseParams ,
755+ isNewManualExpenseFlowEnabled : true ,
756+ } ;
757+
758+ it ( 'returns fieldRequired for manual expense when the date is removed' , ( ) => {
759+ const { result} = renderHook ( ( ) =>
760+ useConfirmationValidation ( createValidationParamsForParticipant ( POLICY_EXPENSE_CHAT_PARTICIPANT , newManualFlowParams , { created : '' , isAmountSet : true } ) ) ,
761+ ) ;
762+ expect ( result . current . validate ( ) ) . toEqual ( { errorKey : 'common.error.fieldRequired' } ) ;
763+ } ) ;
764+
765+ it ( 'returns fieldRequired for distance expense when the date is removed' , ( ) => {
766+ const { result} = renderHook ( ( ) =>
767+ useConfirmationValidation ( {
768+ ...newManualFlowParams ,
769+ isDistanceRequest : true ,
770+ transaction : createTransactionBase ( {
771+ amount : 1000 ,
772+ created : '' ,
773+ iouRequestType : CONST . IOU . REQUEST_TYPE . DISTANCE ,
774+ participants : [ POLICY_EXPENSE_CHAT_PARTICIPANT ] ,
775+ comment : { type : CONST . TRANSACTION . TYPE . CUSTOM_UNIT } ,
776+ } ) ,
777+ selectedParticipants : [ POLICY_EXPENSE_CHAT_PARTICIPANT ] ,
778+ } ) ,
779+ ) ;
780+ expect ( result . current . validate ( ) ) . toEqual ( { errorKey : 'common.error.fieldRequired' } ) ;
781+ } ) ;
782+
783+ it ( 'returns fieldRequired for time expense when the date is removed' , ( ) => {
784+ const { result} = renderHook ( ( ) =>
785+ useConfirmationValidation ( {
786+ ...newManualFlowParams ,
787+ isTimeRequest : true ,
788+ transaction : createTransactionBase ( {
789+ amount : 1000 ,
790+ created : '' ,
791+ iouRequestType : CONST . IOU . REQUEST_TYPE . TIME ,
792+ participants : [ POLICY_EXPENSE_CHAT_PARTICIPANT ] ,
793+ comment : { type : CONST . TRANSACTION . TYPE . TIME , units : { count : 1 , rate : 100 } } ,
794+ } ) ,
795+ selectedParticipants : [ POLICY_EXPENSE_CHAT_PARTICIPANT ] ,
796+ } ) ,
797+ ) ;
798+ expect ( result . current . validate ( ) ) . toEqual ( { errorKey : 'common.error.fieldRequired' } ) ;
799+ } ) ;
800+
801+ it ( 'returns fieldRequired for invoice when the date is removed' , ( ) => {
802+ const { result} = renderHook ( ( ) =>
803+ useConfirmationValidation (
804+ createValidationParamsForParticipant ( POLICY_EXPENSE_CHAT_PARTICIPANT , { ...newManualFlowParams , iouType : CONST . IOU . TYPE . INVOICE } , { created : '' , isAmountSet : true } ) ,
805+ ) ,
806+ ) ;
807+ expect ( result . current . validate ( ) ) . toEqual ( { errorKey : 'common.error.fieldRequired' } ) ;
808+ } ) ;
809+
810+ it ( 'does not return fieldRequired when the date is present' , ( ) => {
811+ const { result} = renderHook ( ( ) =>
812+ useConfirmationValidation ( createValidationParamsForParticipant ( POLICY_EXPENSE_CHAT_PARTICIPANT , newManualFlowParams , { created : '2025-01-15' , isAmountSet : true } ) ) ,
813+ ) ;
814+ expect ( result . current . validate ( ) ) . toEqual ( { errorKey : null } ) ;
815+ } ) ;
816+
817+ it ( 'does not return fieldRequired when the fields are read-only (date populated server-side)' , ( ) => {
818+ const { result} = renderHook ( ( ) =>
819+ useConfirmationValidation (
820+ createValidationParamsForParticipant ( POLICY_EXPENSE_CHAT_PARTICIPANT , { ...newManualFlowParams , isReadOnly : true } , { created : '' , isAmountSet : true } ) ,
821+ ) ,
822+ ) ;
823+ expect ( result . current . validate ( ) ) . toEqual ( { errorKey : null } ) ;
824+ } ) ;
825+
826+ it ( 'does not return fieldRequired when the date field is not shown (pure scan flow)' , ( ) => {
827+ const { result} = renderHook ( ( ) =>
828+ useConfirmationValidation (
829+ createValidationParamsForParticipant ( POLICY_EXPENSE_CHAT_PARTICIPANT , { ...newManualFlowParams , shouldShowDate : false } , { created : '' , isAmountSet : true } ) ,
830+ ) ,
831+ ) ;
832+ expect ( result . current . validate ( ) ) . toEqual ( { errorKey : null } ) ;
833+ } ) ;
834+
835+ it ( 'does not return fieldRequired when the new manual expense flow beta is disabled' , ( ) => {
836+ const { result} = renderHook ( ( ) =>
837+ useConfirmationValidation ( createValidationParamsForParticipant ( POLICY_EXPENSE_CHAT_PARTICIPANT , { isNewManualExpenseFlowEnabled : false } , { created : '' , isAmountSet : true } ) ) ,
838+ ) ;
839+ expect ( result . current . validate ( ) ) . toEqual ( { errorKey : null } ) ;
840+ } ) ;
841+ } ) ;
749842} ) ;
0 commit comments