needn't have done vs didn't need to do (C1 Grammar)

Needn't have + the past participle means you did something, and only afterward it turned out to be unnecessary. The action happened. The regret is that the effort was wasted. This form is mainly British: American English usually says didn't have to for both situations, so the neat contrast on the next card is one you will meet most often in British writing and speech.

needn't have done: you did it, but it turned out pointless

didn't need to: there was no need (it may or may not have happened)

Didn't need to + the base verb means simply that there was no need. On its own it does not tell you whether the thing happened. The wording around it shows that: "I didn't need to pay, so I walked straight in" (skipped it) and "I didn't need to pay, but I paid anyway out of habit" (did it) are both fine.