You can greatly simplify that SQL code which may help you get rid of the problem.
Instead of convoluted IF statements just handle the possibility of one or more of the parameters being NULL
Look at this example table:
create table #demo (CarID INT, Model varchar(10), repdate datetime)
insert into #demo(CarID, Model, repdate) values
(1, 'Test1', '2020-11-10 22:10:00.000'),
(1, 'Test2', '2020-11-11 22:10:00.000'),
(1, 'Test1', '2020-11-12 22:10:00.000'),
(1, 'Test2', '2020-11-13 22:10:00.000'),
(2, 'Test1', '2020-11-14 22:10:00.000')
And here are my test conditions with expected results
set @CarID = 1
set @CarModel = 'Test2'
set @CarID = 1
set @CarModel = NULL
set @CarID = NULL
set @CarModel = 'Test1'
set @CarID = NULL
set @CarModel = NULL
This query will handle
all 4 scenarios
select *
from #demo
where CarId = ISNULL(@CarID, Carid)
and Model = ISNULL(@CarModel, Model)
and repdate between @StartDate and @EndDate
It works because by setting the NULL parameter to the value on each row that we are testing against we are effectively saying
WHERE 1=1
which is always true