The function from the question works correctly. The problem is the formula with the user-defined function that is used in the spreadsheet (quoting from a comment by OP):
The formula includes a redundant comparison of the return value of
MYFILEEXISTS, and the comparison is done wrong: it’s compared to a string
"True". This works in AOO (for some unclear reason), but of course, it should not - and it does’t in LO, and also in MSO (at least in my testing with Excel 2016 with en_US UI on Russian OS - mentioning these details, since it could be locale-specific; if it is, then using that “equivalency” of a boolean value to a locale-specific string is wrong even more).
Since the function returns a boolean result, the correct way is to simply do