Thank you both for your responses!  This is what I think the program is doing.

I noticed that the difference between the repayment amount of $4328 and the Schedule A amount of $1628 was exactly $2700.  That number looked familiar so I did some checking and saw that credit repayment is limited to $2700 when the poverty level amount is between 300 and 400%.

I then went back to my simplified calculation and substituted the 300-400% amount of $2700 into the calculation:

SEHI cost - APTC + amount repaid (using above limit) = $20360-4328+2700=$18732, which is exactly what program calculated (incorrectly, I believe).

If anyone from Intuit reads this, can someone actually check to see if program is incorrectly doing this?  My understanding is that for 2021 there was NO limit on amounts which need to be repaid for a person clearly over 400% of poverty level, such as my client.