Meet the 30-day protection deadline, and hand the deposit back at the end without a dispute.
A deposit must be protected in a government scheme within 30 days. In Scotland it is within 30 working days. You must also give the tenant the prescribed information.
Miss the deadline and the tenant can claim between one and three times the deposit. In England, a court also cannot order possession until the deposit is protected.
Abodient tracks the duty on the property's Tenancy tab, under Paperwork.

Deposit protection shows as missing until you upload the certificate.
Two Inventory items sit alongside it. A check-in inventory at the start is what lets you prove damage at the end. A check-out inventory records the state you got the property back in.
Recording the deposit amount on the tenancy is not the same as protecting it. Protection happens in the scheme, and the certificate is filed here.
Return the deposit, less any agreed deductions, through the same scheme. The check-in inventory is your evidence for anything withheld.