Allow SELECT on column which references another column which references the user

Here's a simplified version of the setup:

There's a "teams" table, a "nodes" table and a "comments" table.

Comments belong to nodes. Nodes belong to teams. Users can be a member of teams by means of a many-to-many join table.

I expected something like this to work, as a SELECT policy on comments:

auth.uid() in ( select profile_id from team_members where team_id = node.team_id )

But it throws this error: missing FROM-clause entry for table "node"

Where am I going wrong?
Was this page helpful?