Join on nested obj attribute in JSONB column along and a varchar column
The keys for the -&gt; or -&gt;&gt; operators need to be supplied as strings:
SELECT * 
FROM events ev 
  JOIN connections con 
    ON con.user_id = ev.user_id 
   AND con.other_user_id = ev.payload -&gt; 'otherUser' -&gt;&gt; 'id'

Or use the #&gt;&gt; operator and pass an array:
SELECT * 
FROM events ev 
  JOIN connections con 
    ON con.user_id = ev.user_id 
   AND con.other_user_id = ev.payload #&gt;&gt; '{otherUser,id}';

Which is basically the same as using jsonb_extract_path_text
SELECT * 
FROM events ev 
  JOIN connections con 
    ON con.user_id = ev.user_id 
   AND con.other_user_id = jsonb_extract_path_text(ev.payload, 'otherUser','id');

Online example