To understand when we need to use a double infinitive, we need to recap how to form the different "levels" of the Konjunktiv II, the German general subjunctive.
The German "Konjunktiv II", or the general subjunctive is used to express hypothetical, unreal or imaginary situations, wishes and desires. In English, we can translate the Konjunktiv II with "would" to express "would be", "would have" and "would do".
Wenn ich mehr Geld hätte, wäre ich glücklicher.
If I had more money, I would be happier.
Wenn ich du wäre, würde ich das nicht tun.
If I were you, I would not do that.
When we add modal verbs to the general subjunctive, the translation into English incudes "could" and "should", "would have to", "would be allowed to", and "would be supposed to".
Ich könnte am Samstag arbeiten, wenn du mich brauchst.
I could/would be able to work on Saturday, if you need me.
Du solltest nicht so viel arbeiten.
You shouldn't work so much.
Ich müsste ihm Bescheid geben.
I would have to tell him/give him notice.
In the same way that we can divide the Konjunktiv II into "with" and "without" modal verbs in the present tense, we can do so in the past tense as well.
The Konjunktiv II in the past tense without modal verbs would be "would have been", would have had", and would have done".
Ich hätte dich angerufen.
I would have called you.
Ich wäre vorbeigekommen.
I would have stopped by.
Ich hätte keine Zeit gehabt.
I would not have had time.
4. "Hätten" and double infinitives
When using the Konjunktiv II in the past tense with modal verbs, we need to use "hätten" (conjugated based on the subject), the modal verb in the infinitive at the end of the sentence, proceeded by the second verb also in the infinitive. This is used to express "would have had to", "would have been supposed to/should have", "would have been able to/could have" and "would have been allowed to".
Du hättest mich anrufen können.
You could have called me.
Wir hätten früher losfahren müssen.
We would have had to leave sooner.
Er hätte etwas sagen sollen.
He should have said something.