Please don't shoot the messenger but, when a gift is given (as opposed to left as an inheritance) the giftee (receiver of the gift) gets a "carryover basis." the basis that the giver of the gift had in the asset
DO realize however, that this came into play TWICE, in your situation
their gift in the house is the basis that you had in it when you gave it to them
So what you are getting back is essentially what you put into the house (purchase price plus any improvements you made before gifting it to them)
The mortgage (although it WAS how funds were raised for paying for the house) doesn't really affect basis - unless maybe you deducted mortgage interest as a business expense while it was a rental ... the capital gains will be net sales price (sales price less selling costs, such as commissions) minus the basis (investment in the house.
Now, if it was gifted back to you and your sister in equal shares (50/50) then you each have 1/2 of the basis in the house (again whatever your parent's basis was. which in this case, was the basis you gifted TO them) and will have a capital gain of your proportionate sales price (1/2) minus the 1/2 of the basis (again, because you originally gifted it to them YOUR original basis)
I still don't see you coming into the chat session, so I'll move us to the "Q&A" mode. … Maybe that will help … (We can still continue a dialogue there, just not in real-time chat, as we can here)
Let me know if you need anything else at all on this ...