First of all there three chain lengths to consider. The absolute minimum is long enough to loop both large sprockets with an inch to spare. The maximum is short enough to loop the small sprockets with the RD able to take up slack before hitting it's dead stop. The third is the best chain length for your purposes between those, based on RD cage angle in various gears.
If the RD is used at capacity all three will be very close or the same, if there's excess capacity you have some freedom to try to optimize chain length. I always err to the long side, so I have the freedom to cut out a pair of links if they ever become damaged.
If the RD capacity is inadequate for the gear range, the minimum will be longer than the maximum, and you have a choice. Either change the gearing or replace the derailleur. Or in borderline, cut the chain to the minimum length, and ride knowing that you won't be able to use the small chainring with the smallest few sprockets. I often go this route setting up road bikes figuring there's no logical reason to use the small chainring with the outer sprockets anyway.
BTW- I never add new links to a used chain, unless it's just about new. Mixing new and old links on a chain increases sprocket wear and thereby raises drivetrain maintenance costs. If you need a longer chain, replace it entirely and save the used one for future use.
__________________
FB
Chain-L site
An ounce of diagnosis is worth a pound of cure.
Just because I'm tired of arguing, doesn't mean you're right.
“One accurate measurement is worth a thousand expert opinions” - Adm Grace Murray Hopper - USN
WARNING, I'm from New York. Thin skinned people should maintain safe distance.