The essential requirement is for that Mac to have been correctly prepared for sale according to What to do before you sell, give away, trade in, or recycle your Mac - Apple Support. Those instructions must be complied with, ideally under your direct supervision.
Removing its firmware password is also a requirement: What is a firmware password on Mac? - Apple Support
If any part of those instructions are not fully complied with, then you will have bought a useless "brick".
... if I was running an older operating system than a new iMac for example?
That will not be a factor because you will be restoring it from your "dead" iMac's Time Machine backup. That will restore everything including its operating system.
Confirm that Mac is configured with internal storage of capacity equal to or greater than yours. The only options for that model were a 1 or 2 TB HDD or a paltry 256 GB SSD. No matter which, if it is the iMac's original storage be advised they have already reached their end of expected service life. If it has been upgraded, investigate.
That Mac's GPU has also been afflicted by a limited service life due to its life-limited internal flash storage. No replacements are available.
If it is not already abundantly clear, buying a Mac of any age is best left for very experienced Mac users. Buying one that old is so unattractive that experienced users won't be interested, unless it's free, in which case it would be best suited for installing Linux Mint, not an antiquated macOS version. High Sierra (the latest that one is capable of) is about to lose its security certificates as they are due to expire in a few short months. That means the software you presumably wish to keep using will not be an option anyway.
Nobody likes to keep older Macs in service more than I do, but a fifteen year old model, even if its hardware is 100% perfect (which it won't be), is certain to be a frustrating experience at best.
You did not ask for my opinion but if you did it would be "don't do it."