Apply_when with more than one statement not working

Hello,

We are currently working on a project with multiple user types and want to apply rules to our collections to ensure correct access.
While writing the rules we encountered an issue. Rules that contain more than one statement in the apply_when are just not working and just throwing exceptions in backend:

error executing match expression: invalid document: must either be a boolean expression or a literal document

The rule is:

"apply_when": {
        "company": "%%user.custom_data.company",
        "%%user.custom_data.type": "supplier"
      }

(With “company” being a field in the document and “supplier” beeing a possible value of the type in the custom data)

Both statements of the apply_when are working solo in other places. But when together - they result into the exception.
Are we missing something? Because in the documentation this is presented as the way to go for multiple statements.

Best Regards,
Daniel

hi
I had a problem like this , i just found the solution
I think the problem is with “company” field.try this:
1-convert rules to advanced rule
2-leave apply_when field empty
3-for read ,write, search,insert field copy and paste your original condition
4-for delete field use this line of code:

"delete":{
        "%%prevRoot.company": "%%user.custom_data.company",
        "%%user.custom_data.type": "supplier"
      }

if that didn’t work,do all previous things and for write field use this code:

"write":{
"%or": [
       { "%%prevRoot.company": "%%user.custom_data.company"},
       { "%%root.company": "%%user.custom_data.company"}
]
,
        "%%user.custom_data.type": "supplier"
      }