Where are you trying to use the_permalink()?
That aside, you have a query nesting issue.
Please see this topic and the topics that are linked to from there for an explanation of nested query issues. https://support.advancedcustomfields.com/forums/topic/nested-post-object-fields/