This is the patchset that seems to work but I need to test it in-depth again because it was depending on a patchset which was only semi-recently merged into TWRP.
https://gerrit.twrp.me/c/android_device_fairphone_FP5/+/6952
The general approach would be the same for FP4 but I couldn’t make it work last time I tried.