If you attempt to connect via a shared session as a guest, the user on the remote Mac needs to accept your request:

If the user hits Cancel, you will not be able to connect. Selecting Share Screen will grant you access so you can share a screen session.
Enable Shared Screen Sessions
Another cause for this error is that shared sessions are not enabled on the remote Mac:
On macOS 13 Ventura or later
- Click this link to open the Sharing settings on your Mac
 - Click (i) under Remote Management (or Screen Sharing if enabled)
 - Click Computer Settings…
 - Enable Anyone may request permission to control screen
 
On macOS 12 Monterey or later
- Click this link to open the Sharing settings on your Mac
 - Select Remote Management (or Screen Sharing if enabled)
 - Click Computer Settings…
 - Enable Anyone may request permission to control screen