As @vletm suggests, MIN or the more modern function MINIFS will return zero rather than an error if there are no matches.
Rather than trying to modify the formula, you might like to use a number format [$-en-US]h:mm AM/PM;;"-";@
to conceal the zeros.
Something that might be of interest for the future (Office 365 in particular) is that the entire array of values can be created by one formula = IF( alternate,
MINIFS( actualLogin, Code, summaryCode, Date, summaryDate ),
MAXIFS( actualLogin, Code, summaryCode, Date, summaryDate ) )
The main challenge is creating the alternating pattern of MAX and MIN.