When a U.S. citizen marries a foreign national who came to the United States on a nonimmigrant visa but overstayed, that's normally a better situation than if the foreign national had entered the United States illegally. That's because, if the immigrant wishes to apply for a green card without leaving the United States through the process known as "adjustment of status," the lawful entry will likely let them do so. (A lawful entry wipes out two grounds of inadmissibility that are a problem for illegal entrants hoping to adjust status: excess unlawful time in the United States, and unpermitted U.S. employment. Their only choice is normally consular processing.)
But could that unlawful employment actually offer one more benefit, allowing the couple to avoid filling out an Affidavit of Support (Form I-864) based on having already racked up 40 qualifying Social Security quarters between the two members of the couple during their marriage? (See Who Is Exempt From Submitting Form I-864 Affidavit of Support.) It's possible, as this article will discuss.
U.S. immigration laws do not require, in the case of qualifying for an exemption from the I-864 Affidavit of Support requirement, that the noncitizen's work have been done with authorization from U.S. immigration authorities. The laws simply require that the applicant satisfies the requirements of the Social Security Administration (SSA) regarding recredit for work done. And to be credited with work quarters according to the SSA, the work needs to have been performed in the name of the person whose number it really is.
It sometimes happens that a foreign national obtains a valid Social Security Number (SSN) during time in the United States on a nonimmigrant visa; perhaps a work visa such as an H-1B. Or perhaps they came to the United States on an F-1 student visa, then applied to USCIS for work authorization during their years in school.
If so, any work done using that valid number should count in tallying up quarters for Social Security purposes. (The foreign national will also need to have earned more than a minimum amount per year; and this amount changes every year, so do some careful checking.)
To check SSA earnings records, each member of the couple will need to go to the My Social Security page of the SSA website and open an account. (Your lawyer, if you eventually go to one, will be very interested to see the printout of what you find here.)
If the foreign national used another person's Social Security Number, or a false number, in order to work, this will not count toward the 40 quarters. It would be worth consulting an experienced immigration attorney to see whether there's a way to fix this situation; and whether it brings up other legal issues in your case.
U.S. immigration laws have many ways of punishing someone for illegal work, but in the case of someone who worked with a valid Social Security Number, entered the United States legally, and is marrying a U.S. citizen, it's unlikely to affect the green card case. Still, you really should try to save enough money to see an immigration lawyer for a full analysis. (See How Expensive Is an Immigration Lawyer?) This is a tricky area of the law, and a small difference in one's personal situation can make a big difference in the legal result.
Need a lawyer? Start here.