Getting flat for 31 days does not technically avoid the wash sale, but if you do it across a year boundary (i.e., December to January), then you can effectively ignore the wash sale for tax calculations.
You've got that backwards. You can ignore the wash sale all year long and trade as often as you want, booking gains and/or losses. At the end of the year, the net carry forward wash sale loss is the issue. If you want to deduct it this year, you cannot re-establish the same position for 31 days after booking that loss otherwise you lose it for the current tax year and must carry it forward.