How would one allow users to edit only some other users entries but not all? Linked via a related field
I managed to implement it, don't know if it's the best way. Ideally I would like to disallow users to edit other entries, then in the EVENT_BEFORE_SAVE grant permissions, but I think the permissions are being checked before EVENT_BEFORE_SAVE so I could not find a way to tap into it before then. 

Therefore I have granted the user permissions to edit other users entries, then the following code will check if the user is in the same organisation, and if they are not set the event isValid to false, which stops it saving. 

Event::on(
Entry::class,
Entry::EVENT_BEFORE_SAVE,
function(Event $event)
{
    // Only do it on front end
    if (Craft::$app-&gt;request-&gt;isSiteRequest)
    {
        // Get Entry Data
        $entry = $event-&gt;sender;

        // Only call it if its sectionId 1 = Projects or 22 = KPIs
        if( $entry-&gt;sectionId == 1 || $entry-&gt;sectionId == 22)
        {
            // Entry Organisation ID
            $entry_organisation_id = $entry-&gt;client-&gt;id[0];

            // User Organisation ID
            $user = Craft::$app-&gt;getUser()-&gt;getIdentity();
            $user_organisation_id = $user-&gt;getFieldValue('organisation')-&gt;first()-&gt;id ;

            if($user_organisation_id != $entry_organisation_id)
            {
                // Disallow!
                $event-&gt;isValid = false;
            }

        }
    }
}


);

Code goes into a plugin init() function I have for my site.