It is tough for a kid who has had a history of teachers not understanding, who are trying to rebuild trust, to have something like this happen. Unfortunately, subs have a tough job and are almost certainly going to make mistakes. Perhaps, you could just remind him that whenever there is a substitute, there is a chance that he will not be understood and that, even though it is not fair, he should not take it personally. I would emphasize the good relationship he has with his teacher, the one who knows him.

My DS has rarely had any problems with his regular teachers but has been sent to the principal by subs. In 5th grade he had an especially chatty relationship with his regular teacher with whom he kept up a pretty regular banter. She was a great teacher and kept 32 pretty disruptive kids under control and learning most of the time. With the sub, there was already some level of confusion and chaos. When DS disagreed with her on some point she was trying to explain (and, yes, she was wrong) and she asked him to let her finish her explanation and DS didn't let it go but kept arguing(because his regular teacher would have enjoyed the back and forth), he was sent to the principal. The principal understood the situation, chatted with him a bit, let the tempers settle and let him go back to class without any consequences.

What I went over with DS after that incident is that being a sub is a hard job. The subs don't know the kids, have a lot that they are trying to do right but haven't done before, and so are likely to make mistakes. None of us is perfect. He shouldn't take a sub's mistaken understanding of him personally and perhaps in the future he could be a better "host" to the sub, since I know (from first-hand experience) that sometimes his banter can be annoying.