Form and rules
How it works
Needn't + base verb and don't need to + base verb both mean there is no present or future necessity.
Didn't need to means there was no past necessity; by itself, it does not tell us for certain whether the action happened.
Needn't have + past participle means the action definitely happened, but it was unnecessary.
Do not confuse needn't have done with didn't need to do: the first confirms the action, the second focuses on absence of necessity.
Need can also be a normal main verb and then uses ordinary tense forms: I need to leave; she didn't need to come.