Often with invalid brushes, they appear fine in Hammer, but they are not. Invalid could mean several things, but the most common are the following:
1: Two faces of the brush are on the same plane. So one flat side of the brush is actually two flat faces. This is not allowed.
2: A brush is concave.
3: One face is twisted or bent and is not perfectly flat. Often caused with vertex manipulation.
Hammer and the compile tools will do their best to fix it if you don't do it yourself. The results are unpredictable and often awful. You should seek out problem brushing in Hammer and rebuild them. It has nothing to do with your HL program.