The word “that” is a problem in a clause in that it doesn’t always have something that it is doing in the clause it starts and can therefore be left out. It is equally correct to say.
...I know that he was there.
...I know he was there.
When an adverb clause is dropped in after “that” in this sentence, the adverb clause needs to be surrounded by commas.
...I know that, when she came in, he was there.
If we were to take out the adverb clause, the sentence would go back to “I know that he was there.” Thus two commas are necessary. There is nothing being separated in this sentence.
The problem is that bad grammar sometimes puts “that” in front or in back or in both places with respect to that adverb clause. In any event, the commas surround the adverb clause.
"Bad grammar/good punctuation."
...I know that, when she came in, he was there.
...I know, when she came in, that he was there.
...I know that, when she came in, that he was there.
...I know, when she came in, he was there.
Happy punctuating!
Margie