Teen Mom 2 star Leah Messer has settled on a joint-custody arrangement with ex-husband Corey Simms over their six-year-old twin girls.

Four months ago, Simms was awarded primary custody of daughters Aliannah and Aleeah, and Messer was devastated to learn she could only spend weekends with them.

However, Messer, 23, got her act together, fought hard for her children and officially regained shared custody of the girls on Wednesday, Us Weekly reported.

"Leah is doing great," an insider told Us. "She was never asking for full custody. She wants the girls to be able to see their dad."

Messer will now have Ali and Aleeah on Thursdays through Sundays before handing them over to Simms, 25, on Monday for the remainder of the week. Simms will also get the girls one weekend a month, and he and Messer have agreed to "split the bills 50-50" as they continue to co-parent.

A source close to Simms told the magazine they "came to an agreement that works best for the girls."

Although Messer completed 30 days of treatment in rehab for anxiety and depression last summer, a judge ruled in Simms' favor in October because she had been accused of missing Ali's physical-therapy appointments to help her muscular dystrophy, abusing prescription pills and constantly failing to get their girls to school on time.

Messer had angrily called the allegations "a slap in the face" and insisted they were false. She assumed Simms was just happy collecting hundreds of dollars worth in child-support payments a month from her.

However, Messer later passed multiple drug tests and managed to come up with evidence she's a better mother than people suspected.

"[Leah] proved in court that the kids were not tardy to school, so the judge said there was no reason the kids shouldn't be with their mom predominantly," the insider said, adding that the judge did indeed throw out the allegations in court Wednesday.

"She had confidence that she would be proven right and get her custody rights back."

Messer also has a two-year-old girl Adalynn with her second ex-husband Jeremy Calvert, whom she divorced in 2015 after three years of marriage. The source close to Simms told Us that he also has three children. Simms just welcomed a baby girl named Remi with his current wife Miranda in November of last year.