title: Firestore rules functions get() and exists() not returning desired result. What am I doing wrong?
body: <p><a href="https://i.stack.imgur.com/fA1GA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fA1GA.png" alt="enter image description here" /></a></p>
  <p>This is barebone structure of the Firestore database that I am using.
  edit: all names are in small letters</p>
  <p>The rules I want is</p>
  <ol>
  <li>admins of a hostel can read all the rooms of the hostel</li>
  <li>residents of a room can only view the room if the room has the residents id in its
  residents subcollection</li>
  </ol>
  <p>1 is working as intented
  2 is not</p>
  <pre><code>match /databases/{database}/documents {
  
    match /hostels/{hostelId} {
      allow read, write: if request.auth.uid != null;
  
      match /rooms/{roomId} {
       allow read, write: if exists(/databases/$(database)/documents/
                                 hostels/$(hostelId)/admins/$(request.auth.uid));
  
       allow read: if exists(/databases/$(database)/documents/
                           hostels/$(hostelId)/rooms/$(roomId)/residents/$(request.auth.uid));
  
         }
      }
  }
  </code></pre>
  <p>while reading rooms as resident i get error</p>
  <pre><code>Null value error. for 'list' @ L49
  </code></pre>
  <p>I also tried with get() by reading a boolean field of resident document and no luck.</p>
  <p>what am i doing worng? Is there a limit to exists() and get() path argument depth? Any help would be much appriciated</p>
  <p>the code i use to query rooms by resident is</p>
  <pre><code>let q = collection(this.hostelCollection, 
             this.residentSnap.get('hostel_id'), &quot;rooms&quot;)
  let docs = await getDocs(q);
  </code></pre>
  <p>resident document has hostel_id field containing hostel id</p>