2019 iMacs do not support Target Display Mode. Target Display Mode went away when the first 27" 5K Retina iMac came out in Late 2014, and never returned. New Macs don't support using any iMac (even a 2009 – mid 2014 one) as a Target Display.
See the bad news here: Use your iMac as a display with target display mode - Apple Support
There are third-party "workaround" products such as Luna Display (Astropad), or Duet Display, but even if you run a cable between the MBP and the iMac, they won't be the same as a first-class hardware-supported connection to a real monitor.
AstroPad acknowledges this on their site:
AstroPad – Use Your iMac as a Monitor: A Step-by-Step Guide [2024]
"Like any product, Luna Display does have limitations and it’s not recommended for high-motion content. For example, I wouldn’t recommend using Luna Display for gaming or video editing.
Since Luna Display is squeezing a 5K display through a USB cable, when lots of motion occurs on-screen (like from video playback or moving a window quickly) the screen can temporarily become pixelated before it renders in at full resolution."