The 2019 iMac cannot be used as a primary monitor for the Mac mini.
There is a third-party option, Luna Display (~$100), but its use is not suitable for enabling the iMac to be the primary display. Latency and pixelation are factors that make the solution problematic.
❝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.❞ - Luna website (Their emphasis, not mine.)
To use Luna you will need a primary display in order to setup the Mac mini and then to setup the Luna hardware and software.
Save yourself the headache and simply budget for a new monitor for your new mini. A display that compares favorably to that of the 2019 iMac can be had for ~$150-$350. And it'll just work.