How do I make sure that a new washing machine doesn't overflow?
The only real answer is to fix the root plumbing issue.  You are basically begging for problems by not fixing it. This can do serious damage to your house over time.  There might even be health issues if the traps are not holding water (water flowing out of them due to incorrect slope) and sewer gasses are escaping into your house, not to mention the likelihood of mold too.

As a temporary measure, I would recommend putting in place a laundry tub and have the washing machine empty into the tub. This way, the tub acts as a buffer and holds the water while it drains.   New HE machines don't use that much water compared to top loaders so this might help too.

But seriously, get this fixed.