All box filtering

Your gist seems about right. The rules are run in order. You can easily try it out in roundcube.