corrupted /data partition?
Try doing what it suggests... run e2fsck -b 8193 /dev/block/platform/msm_sdcc.1/by-name/userdata. If that doesn't work, try running mke2fs /dev/block/platform/msm_sdcc.1/by-name/userdata.

You can also boot into fastboot mode and run fastboot erase userdata.

If none of these work, please elaborate on this "long story". How did you mess up your data partition with TWRP? Got any logs/error messages/steps to reproduce? I've been using TWRP ever since I started using custom ROMs and never had an issue.