getCurrentItem when filter does not match

I’m trying to get a specific value of current item of a dataset which is filtered based on another dataset (has a reference to it in the collction) e.g email dataset filtered by person dataset.

I understand that even when the filter does not match the other dataset, getCurrentItem() still returns an object which is null or undefined.
Due to that I’ve added a check for it, so if it is null or undefined I’m not trying to get the field value.
In preview mode it works great but when I check it on live site it throws null value error.
Furthermore, when I open the chrome debugger and checking the getCurrentItem object it reports that it is not available.
PFA the related code from the chrome debugger.

Does anyone have an explanation for this?

Remove this code:

email = null;

(line 353 & 355)

& 341
It’s really unclear why you set it to be null there.

Thank, but it is not my code, it is the debugger showing the value of the email variable when the code reaches row 361. I didn’t set it to null (all the brownish highlighted texts are chrome debugger texts not my code).
I would expect that the getCurrentItem() return undefined or null if there are no matching rows in the dataset I think it returns an object with the email value in it as null.

I see. Can it be the collection permissions?