In NYC, on a joint lease you and your roommate are both jointly and severally liable, meaning the landlord can collect the full rent from either of you. If she moves out and the friend doesn’t pay, you owe the whole rent. First, don’t accept the replacement until you meet them and vet them. You are not obligated to accept her friend. You can propose your own roommate or refuse. If she leaves without landlord consent, she remains on the lease and legally responsible, but practically you’d have to sue her in small claims for unpaid rent.
For the security deposit: don’t return her share directly. The security stays with the landlord until the tenancy ends. If the new person pays you her share of the existing deposit, you can give your roommate her portion, or negotiate deductions if the new person doesn’t cover exactly. Better: have the new person add their own deposit through a written roommate agreement that addresses move-out, utility bills, and what happens if they leave early.
Get landlord approval in writing. A simple “replacement” doesn’t let the original roommate off the hook unless the landlord releases her from the lease and adds the new roommate—that’s a lease assignment or a new lease. Ask management what they require: application fee, credit/income check, possibly a new rider. Also check if your lease has a sublet clause; even if it says no sublets, NY Real Property Law allows you to request consent for sublet under certain conditions, but you must follow procedure. Don’t do this on a handshake.