I don't know if this would work for all, but it definitely worked for me, so I am sharing my way -
My device recently got upgraded to Android 13 from Android 12 (Xiaomi Redmi Note 10 Pro Max), and before that, I was able to access data/data folder via adb connection over Wi-Fi. But, when I tried to access the data/data folder, it popped this message - 'error executing shell command pm' below that folder. So, I did some research and found that the adb was trying to access my work profile, rather than my user profile.
I then switched the user via -
Get the user id - 'adb shell pm list users' (mostly the id will be '0' for the default user, which was my case.)
Switch to default user - 'adb shell am switch-user USER_ID' (USER_ID = 0, in my case)
If you try to switch to work profile, you might get -
java.lang.SecurityException: Shell does not have permission to access user 10 at com.android.server.am.UserController.enforceShellRestriction(UserController.java:2625) at com.android.server.am.UserController.switchUser(UserController.java:1840)
If still you are not able to acces data/data folder, then uninstall/disable work profile or the app such as 'Company Intune Portal' or the app that you employer has asked you to get installed on your device and then do the above steps again. Hopefully, you may have regained access to the data/data or other folders that were not accessible before.
If that doesn't work, try to 'Revoke USB debugging authorizations' in the 'Developer Options' and follow the above steps again.
Or, even if that doesn't help you, try to restart both your PC and mobile device, and first disable Developer Options and Re-enable it again. Don't forget to enable 'USB debugging'.
You may try to kill the server and re-enable it, if none of the above works-
'adb kill-server'
'adb start-server'
'adb devices'
Don't forget to reinstall/enable what you had uninstalled/disabled :)
EDIT: After some time of hassleless usage, I am now getting the same error. If someone else has a better solution, please let us know.
EXTRA: To get the current user -
adb shell am get-current-user # returns USER_ID of the foreground user
adb shell cmd activity get-current-user # alternative command