A snapped off derailleur caused my chain to loop itself so unsure whether it needs replacing.
If it's just tangled, untangling it is fine, but if your derailleur has suffered there's a good chance your chain has too, which will weaken the chain. Laying it out on a flat surface, it should look flat once you've taken out the loops.
If you've got twisted links, they're likely to snag on the derailleur or gears, possibly only under load. If you try to straighten them, they'll probably end up stiff, and will be weaker. I recently trashed a rear derailleur and definitely had to replace the chain. Some links were badly twisted, and even with those removed the remaining chain was fragile (I snapped it twice in 5km of gentle riding). One almost new chain in the bin. You may be lucky, or you may be in the same position.
Answer: it depends.
You don't necessarily need to replace a chain just because it tangled into itself. Derailleur-compatible chains are designed with a considerable amount of sideways flex to not interfere with the shifting performance.
It may be tedious and very fiddly, but try to unwind it. It's best to do it while the chain loop is disconnected as unwinding it while still in a loop will feel like solving a rubik's cube.
That said, if the chain got so tightly tangled that it's stuck, you can try disassembling the tangled section with a chain splitter tool.
Next, you inspect the chain's links. If some of the links are only slightly bent, try to bend them back to place with some pliers or a hammer. If the bent links are very hard to fix, then don't bother. That's the time that you buy a new chain.
If you are in a racing kind of situation where nothing should go wrong as much as possible, you can unwind the chain, fix it (if possible), and then just save it as a spare/emergency replacement while you buy a fresh chain.