Firestore Rule with hasAny is not working

  Kiến thức lập trình

I have following firestore rule, which is not working:

allow read: if (get($(database)/documents/users/$(request.auth.uid)).data.admins)

What I want is that there is a messages collection and there is a chats collection. Messages Document has a reference to a chat document and that chat document has an array of user doc references. User also has a field called admins, which is also a list of user document references. Now, I want the user that is sending the request, to be able to read the messages doc, if any of the user in chat’s users field is in the admins field of that user.
This should be working, but I am still getting the permission denied error.
Why would that be?