diff --git a/src/entities/conditional-logic/model/conditions.ts b/src/entities/conditional-logic/model/conditions.ts index 300288a1e..6e6cf9948 100644 --- a/src/entities/conditional-logic/model/conditions.ts +++ b/src/entities/conditional-logic/model/conditions.ts @@ -145,8 +145,12 @@ export const isGreaterThanTimeRange = ( }>, { time, fieldName }: { time: HourMinute; fieldName: string }, ): boolean => { - if (!isValidTimeFormat(time) || !timeRange) return false; + if (!time || !timeRange) return false; + const selectedTime = getTimeBasedOnFieldName(fieldName, timeRange); + + if (!isValidTimeFormat(selectedTime)) return false; + const normalizedTime = typeof time === 'string' ? parseTimeString(time) : time; @@ -162,9 +166,12 @@ export const isLessThanTimeRange = ( }>, { time, fieldName }: { time: HourMinute; fieldName: string }, ): boolean => { - if (!isValidTimeFormat(time) || !timeRange) return false; + if (!time || !timeRange) return false; const selectedTime = getTimeBasedOnFieldName(fieldName, timeRange); + + if (!isValidTimeFormat(selectedTime)) return false; + const normalizedTime = typeof time === 'string' ? parseTimeString(time) : time; @@ -180,9 +187,12 @@ export const isEqualToTimeRange = ( }>, { time, fieldName }: { time: HourMinute; fieldName: string }, ): boolean => { - if (!isValidTimeFormat(time) || !timeRange) return false; + if (!time || !timeRange) return false; const selectedTime = getTimeBasedOnFieldName(fieldName, timeRange); + + if (!isValidTimeFormat(selectedTime)) return false; + const normalizedTime = typeof time === 'string' ? parseTimeString(time) : time; @@ -198,8 +208,12 @@ export const isNotEqualToTimeRange = ( }>, { time, fieldName }: { time: HourMinute; fieldName: string }, ): boolean => { - if (!isValidTimeFormat(time) || !timeRange) return false; + if (!time || !timeRange) return false; + const selectedTime = getTimeBasedOnFieldName(fieldName, timeRange); + + if (!isValidTimeFormat(selectedTime)) return false; + const normalizedTime = typeof time === 'string' ? parseTimeString(time) : time;