How to show certain links if a previous link was chosen

So I want to show only certain links if a certain previous link was chosen.

For example:

<<link “I like girls only.” “Girls”>>
<<if $name === “John”>>
<<set $sex = “straight”>>
<>
<<set $sex = “lesbian”>>
<>
<>

<<link “I like boys only.” “Boys”>>
<<if $name === “John”>>
<<set $sex = “gay”>>
<>
<<set $sex = “straight”>>
<>
<>

<<link “I like boys and girls.” “Both”>>
<<set $sex = “bisexual”>>
<>

If John or Jane had met someone else previously before this link and picked their gender, for example:

<<link “A woman had greeted me.” “Andrea”>>
<<if $name === “John”>>
<<set $sex = “straight”>>
<>
<<set $sex = “lesbian”>>
<>
<>

<<link “A man had greeted me.” “Andy”>>
<<if $name === “John”>>
<<set $sex = “gay”>>
<>
<<set $sex = “straight”>>
<>
<>

How do I make it so that the first example only shows the links boys and both if your name is John and girls or both if your name is anything other than John?

Sorry if this was confusing to follow. I’m using the latest version of twine and sugarcube.