It gets complicated as a number of items determine compatibility.
cog spacing, cable pull of shifter, and ratio of RD movement per length of cable pull. Then you throw in throw distance of RD & shifter, max cog size, and chain wrap capacity of RD.
Then you can throw in a number of different manufacturers and their variations and "special designs" as well.
Their are some "general rules" with lots of exceptions and workarounds.
Science Behind the Magic | Drivetrain Compatibility ? Art's SLO Cyclery