Also, there is one more reason that was not mentioned before:
If you used enabled option in useQuery than such queries are ignored by invalidateQueries. From docs:
https://tanstack.com/query/latest/docs/react/guides/disabling-queries
The query will ignore query client invalidateQueries and refetchQueries calls that would normally result in the query refetching.