No, administrators need to use a separate deployment or manual change to specify the sharing setting. You do, however, need to specify the sharing model in your <Object-Name>.object-meta.xml file if you want to use related features. For example, AccountShare will only be available in your Unlocked Package if sharingModel is set to Read or Private.
After a lot of troubleshooting, we found out that the issue was with the community permission for users. Since the community user was not permitted to see other users, the trigger was unable to assign the case owner as the internal user(because before trigger checks all the permissions and FLS)
To resolve the issue, go to Setup > Sharing Setting and check ...
You can't share to a Profile, only a User, Group, or Role (and combinations thereof). You'd have to create some sort of integration to add/remove users to Public Groups based on their profile, then you could share records with that Public Group. If you do this, you won't have to worry about filtering by using the checkboxes, which will eventually have non-...
If you need to update OwnerId of contact with the same user for all the records, you can configure it in Community Preferences instead of trigger.
Follow these steps:
Go to All Communities
Select the Community you are working on
Click on Administration
Under Record Ownership, set a Default Owner
In Master detail relationship detail objects sharing is controlled by parent. You have to query on tasks ParentObjectShare object to get sharing table of task.
E.g you want to query sharing information of tasks related to Case.
Select RowCause, UserOrGroupId, from CaseShare WHERE CaseId = : taskObj.WhatId