Tagging a file based on the folder it sits in

I can't get hazel to run a rule based on the name of a file's containing folder. For example, if a file's containing folder name is "A", then do B.
I have tried matching to "folder name", "document containing", and "containing folder names", and nothing seems to work. What am I missing?
I have tried matching to "folder name", "document containing", and "containing folder names", and nothing seems to work. What am I missing?