I think your problem is that, as you said, the loan has a reduced basis during the year when repayment occurs and the loan basis may have been restored at year end.  The repayment with loan basis at less than face value does create taxable income to the shareholder, and its character is dependent on the loan itself.  If the loan has been formalized with its terms then the income triggered by repayment will be capital gain. If, on the other hand, if the loan is open ended and not formalized, then