Nearly everyone who signs a lease with a friend signs up to something they have not been told about, and only discovers it when the friendship or the arrangement ends.
Joint and several liability
When two or more people sign one lease as tenants, each of you is liable for all of the rent, not your share of it. If your roommate stops paying, the landlord is entitled to pursue you for the entire amount. The fact that you paid your half is not a defence.
Damage caused by one co-tenant, or by their guest, is the responsibility of all of them. So is an eviction: an application for arrears names every tenant on the lease, and an order to vacate applies to everyone.
When one person leaves
What people assume
That the leaver gives notice, comes off the lease, and everyone else carries on with a new person.
What actually happens
A co-tenant on a joint lease generally cannot end their own tenancy while the others remain. Notice from one tenant purports to end the whole tenancy, which is not what anyone wants. In practice it takes the landlord's agreement to substitute someone.
The workable route is a written agreement with the landlord: the departing tenant is released, the incoming one is added, everyone signs, and the deposit is sorted out between the tenants rather than by the landlord. None of it is automatic and none of it happens without the landlord agreeing.
Roommate agreements
A written agreement between you and your roommates covering rent shares, utilities, deposits, notice to each other, and what happens if someone leaves early. It does not bind your landlord and it does not change the lease. What it does is give you something to point at when the disagreement is with each other rather than with the landlord, and that is where most roommate disputes actually live.
Someone living in the unit who did not sign the lease is an occupant, not a tenant. They have no direct relationship with the landlord, no right to stay if the tenant leaves, and cannot be pursued by the landlord for rent. If you are the one not on the lease, you are far more exposed than you think.
Co-tenancy questions turn on the specific wording of your lease and on whether you are co-tenants or separate tenants of the same landlord. Worth a paralegal's read before anyone gives notice.