How do I make a yarn dialogue that lets me buy apples if I have enough gems but only if I have less than 4 apples?

How do I make a yarn dialogue that lets me buy apples if I have enough gems but only if I have less than 4 apples? This is what I tried:

<< set $dialoguesize_Yarn to 3 >>
<< if $numberofapples_Yarn gte 4 >>
Giblard: Due to an apple shortage, I can’t sell apples to anyone who has more than 3 apples.
<< elseif $numberofapples_Yarn lt 4 >>
Giblard: Hiya Gelbo. Wanna buy an apple for 5 gems? Eating one will restore one heart.
[[ Yes|Yes]]
[[ No|No]]
<< endif >>

I also tried doing it a different way: first I made Giblard ask if you want to buy apples. Then if you clicked Yes, it checked if you had enough gems and then checked if the number of apples you already had was greater than 3. If you had more than 3 apples Giblard was supposed to tell you he couldn’t sell to people with more than 3 apples. This didn’t work either. Are you not allowed to put 2 if statements in a row in Yarn?

I wish there was a simpler dialogue system in GDevelop. It would be great if there were a system like that in GB Studio. It’s very easy to use.

Thanks.