Even if the other dependency tests are met, you are not allowed an exemption for your dependent if he or she files a joint return. (Exemptions are no longer available starting with the 2018 tax year)
Joint Return Test
You generally can't claim a married person as a dependent if he or she files a joint return.
You can claim a person as a dependent who files a joint return if that person and his or her spouse file the joint return only to claim a refund of income tax withheld or estimated tax paid.
Example 1—child files joint return.
You supported your 18-year-old daughter, and she lived with you all year while her husband was in the Armed Forces. He earned $25,000 for the year. The couple files a joint return. You can't claim your daughter as a dependent.
Example 2—child files joint return only as claim for refund of withheld tax.
Your 18-year-old son and his 17-year-old wife had $800 of wages from part-time jobs and no other income. They lived with you all year. Neither is required to file a tax return. They don't have a child. Taxes were taken out of their pay so they file a joint return only to get a refund of the withheld taxes. The exception to the joint return test applies, so you aren't disqualified from claiming each of them as a dependent just because they file a joint return. You can claim each of them as dependents if all the other tests to do so are met.
Example 3—child files joint return to claim American opportunity credit.
The facts are the same as in Example 2 except no taxes were taken out of your son's pay or his wife's pay. However, they file a joint return to claim an American opportunity credit of $124 and get a refund of that amount. Because claiming the American opportunity credit is their reason for filing the return, they aren't filing it only to get a refund of income tax withheld or estimated tax paid. The exception to the joint return test doesn't apply, so you can't claim either of them as a dependent.
See Publication 501: https://www.irs.gov/publications/p501#en_US_2020_publink1000220877