Developer Zer0xFF released a pretty useful tool for hacked PS4 owners: PS4_db_rebuilder.

In some cases, your PS4 might crash and get your games database corrupted. The official way to fix this is to restart the PS4 in safe mode and do a “rebuild database”. Unfortunately, if you have a hacked PS4 and a bunch of fpkg files (homebrew or “backups”) installed, the official tool will not retrieve those, and although they’ll still use space on your hard drive, you’ll be unable to reach them in any way (formatting + reinstalling everything probably being the only option).
PS4_db_rebuilder addresses this issue by actually retrieving the fpkgs and fixing the database by including them as well.
From the developer, as to specifically who can benefit from this tool:
there seem to be a small level of confusion about this, especially from people that never had a db rebuild before, so to those lucky few, if your PS4 crashes just at the right time, it will corrupt your game list database and the next time the PS4 boot it will try to rebuild it. When that happens, the PS4 will ignore all your fpkgs, and so, they won’t show up in the the PS4 menu, nor the storage menu, so you won’t be able to play or remove them, but they are there and will still count toward your storage space.
This script, will find those games and add them to the database again. It don’t nothing else. If you’re upgrading your hdd, if you’re formatting your PS4, if you have your games on external HDD, if you’re restoring a previous backup, this does nothing for you.
Download and use PS4_db_rebuilder

PS4_db_rebuilder is a python script that you can download from the developer’s github here. (You’ll need Python to run this).