I hate the archive/all mail feature. You basically have to set gmail up in a browser. So go to gmail in a browser and go to settings. There should be a tab for the labels. You can turn on/off which are shown as folders to IMAP. Uncheck the box for All Mail. That is the important one to turn off, but I also don't want Google's starred or important to show up on my Mac. I also disable the spam from IMAP because I trust Google's spam filter and do t want those on my Mac anyway.
So I don't have rules/filters on the Mac side at all, but I can move messages from my inbox on the Mac to any of my other folders and it gets reflected correctly if I go check gmail in a browser. It also seems correct on the Mac Mail side. So I imagine your Mac side filter will work fine to move messages around.
The other thing that can cause issues is if in gmail in the browser, you add multiple labels to emails. The problem is that gmail's labels concept doesn't work correctly with IMAP folders since an email can only be in one folder. That, I think, is the root cause of IMAP problems whe the All Mail feature is on-gmail has the folder in multiple place (all mail, inbox, and one or more other folders) and that just pisses off IMAP implementations. So basically gmail has a very non-standard implementation of IMAP that they shoehorned on after-the-fact when they after they had the all mail and labels concept.