Scenario: A 'Customer Community' License user logs into a community and creates a case, which is automatically assigned to a queue. A trigger on case invokes a future method (of a class declared
without sharing) to recalc sharing by identifying 'Customer Community Plus' user(s) who should have access to the case. The future method queries for existing
CaseShare records, deletes any which no longer apply, and adds any which do not apply. This is consistently failing when inserting
CaseShare records with:
System.DmlException: Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: 
I have confirmed via debug logs the following (for a given test case):
- The code is identifying 2 users who need new
CaseSharerecords exist prior to the attempted insert.
- Both users have licence 'Customer Community Plus'.
- Both users have the same Profile, and that profile includes Read, Create, and Edit on Case, and has access to the Case Record Type in question.
- Neither user belongs to the queue that owns the case.
- When logged into the org as a SysAdmin, I can view the case and manually share the case to both users.
I've run out of things to check. I should be able to share this case with Customer Community Plus users via Apex Sharing, and I've checked everything else I can think of. What am I missing?