oh that's not good!
it looks very much like this. In that case, it was the flex cable on the notebook. Weird that it happened with your iMac since it would not likely have a flex ribbon to damage. Your 27" *may* have the design that actually allowed the GPU to be swapped, so that might be something to explore.
have you tried with an external display to see if the same thing happens?
Well, first thing, check if the artifact exists on an external screen. This will help point to whether or not the problem arises from the screen/cable or gpu. It looks like cable issues with your model are somewhat common with folks popping their imacs open for upgrades, repairs etc. .
My iMac succumbed to a faulty GPU which was very common for the a112 model. Initially I gave it a lease on additional life with a reflow in the oven, new thermal grease & pads alongside SMC fan control. After this tune up of sorts I got a couple extra years of life however ultimately it did fail completely. I replaced it with another gpu and the iMac is rock solid. It currently lives in its box in the closet. I’d love to pull it out again but don’t really have a space for it ATM.