This is right. Though it is unfortunate. There might already be a ticket out to fix that, but I certainly don’t know where it is.
You’ll have to put the Pagination function in each branch of If functions. I like to use a helper function in js to make defining these kind of UDFs easier.
The following is part time of a topic on GraphQl, but this bit is as every bit of relevant for plain FQL.
UPDATE (April 2023): I replied again with a link to an example in documentation of creating a pagination UDF.