The (past) subjunctive II is usually used to express imagined results in the past that are the opposite to the reality.
Wenn mich jemand gewarnt hätte, hätte ich den Fehler nicht gemacht.
"If someone had warned me, I would not have made the mistake." As it is, I did make the mistake. (Imagined result = Not making the mistake. Reality = Making the mistake.)
The subjunctive II can be used with a modal verb.
Ich hätte den Fehler machen können.
"I could have made the mistake." As it is, I did not make the mistake. (Imagined result = Making the mistake. Reality = Not making the mistake.)
Now, in the sentence in this thread
Ich habe den Fehler fast gemacht.
"I almost made the mistake (but did not)." That is the reality.
chirlu suggested that it should be
Ich hätte den Fehler fast gemacht.
Why would subjunctive II be needed here? There is no imagined result contrary to the reality.