First of all, the subtitle should read "Just when I thought there was peace..."
Both of those sentences would be grammatically correct, but they do not mean the same thing, exactly.
Just when I thought there was peace and we'd resolved one issue, this happens.
This usage is in present tense, so the sentence refers to something going on right now. Better example, with context.
Context: It just started raining
Just when I get my tools out, this happens!
It could also be used in prose.
When you pull this lever, this happens.
Using the past tense makes this a story, so to speak. It happened in the past. It has already happened...
Just when I got my tools out, this happened [it rained]
When I pulled the lever, this happened.
After the dog bit my toes off, this happened.
Backing up to the "this happens" explanation, I realized that I used the present tense and probably caused some confusion.
Just when I thought
This, alone, is a statement of time for something to happen, in present or past. It can be rearranged to look like this
This happens just when I thought [...]
You need timing to separate the past from present.