Task access is determined by list & task access. You can always see who has access to a specific task via the task Share menu:
A few examples of how task access works:
If you have a task that is only on private list "#secret-stuff", only users who have access to that list OR who have been specifically added to that task will be able to see that task.
If you have a task that is on both private list "#secret-stuff" and all members list "#roadmap", anyone who has access to at least one of those lists will be able to see the task.
If a user does not have access to a task, even if they have the link or URL to it, they will not be able to see the task and instead see an error message. They cannot search for the task and it will not show up in smart lists.
For more info on sharing & list permissions, see: https://intercom.help/height/en/articles/3584125-sharing-list-permissions