Please check following tips to troubleshoot the issue.
1.Go to Site permissions -> Change how members can share -> Set Site owners and members can share files, folders, and the site. People with Edit permissions can share files and folders.
2.Make sure you have at least Edit permission for the site collection.
3.Go to Site Settings -> Site collection features -> Deactivate Limited-access user permission lockdown mode feature.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.