The basic tax-loss harvesting wash sale rules are you can’t sell or re-buy the same security within 30 days and claim the realized losses against your income.

But, some people wonder, “What happens if I bought stock within 30 days and want to tax loss harvest the same stock I bought more than 30 days ago?”

Well, you just sell all the shares you’re tax-loss-harvesting with and the shares you bought within 30 days too.

Straight from the horse’s mouth: > More or less stock bought than sold. If the number of shares of substantially identical stock or securities you buy within 30 days before or after the sale is either more or less than the number of shares you sold, you must determine the particular shares to which the wash sale rules apply. You do this by matching the shares bought with an equal number of the shares sold. Match the shares bought in the same order that you bought them, beginning with the first shares bought. The shares or securities so matched are subject to the wash sale rules.– p56 of IRS Form 550 accessed 2/28/20. https://www.irs.gov/pub/irs-pdf/p550.pdf