The Supreme Court in its judgment of July 25, 2019 (reference number III CZP 14/19) decided that the value of the mortgage is not taken into account when determining the value of the property, unless there are special reasons to consider taking into account the value of the mortgage:
In a case concerning the division of joint property of spouses, including a property encumbered with a mortgage securing a bank loan to the spouses, the court - granting this property to one of them - determines its value excluding the value of the mortgage, unless there are compelling reasons to consider it.
This was another ruling in which the Supreme Court made such a view. Earlier, this position can be found in the decision of the Supreme Court of January 26, 2017 (I CSK 54/16) - see the text of the entire decision
In practice, this means that the spouse paying off the other half of his flat is still obliged to repay the entire loan. This may give rise to numerous subsequent complications in the settlement of the loan between the spouses and the bank.
On the other hand, the bank's interests are additionally secured - you have to remember about art. 76 clause 12 of the Land and Mortgage Register Act, which states that if a co-owner of a property whose share was encumbered with a mortgage is entitled to repayment, the claims on this account of his mortgage creditor shall have the statutory lien.