When I reached there, I realised that I ______?
When I reached there, I realised that I ______?
Explanation
The phrase "needn't have gone" indicates that the action was unnecessary but was done anyway.
This is the correct use of "needn't have" in a past context to express regret or realization.