A. Hardly had
B. Had
C. Had better
D. If
‘Hardly had’ and ‘had better’ when used doesn’t make any sense. ‘If’ would have been used when the words after the blank were ‘he had invited …….party’. Therefore option B is correct.
Had he invited me, I would have attended his birthday party.