The stock market sell-off in 2022 has mirrored the decline in gross domestic product (GDP), a key metric that measures the value of goods and services produced by the economy. In the first quarter, real GDP (adjusted for inflation) fell 1.6%. 

Although the economy hasn't officially entered recession territory yet, it's moving in that direction. The National Association of Home Builders (NAHB) expects real GDP to decline by at least 1.5% for the second quarter. 

About 90% of Home Depot's (HD -1.77%) business comes from homeowners, either directly from do-it-yourself customers or indirectly through professional contractors. When the economy is weak or housing prices are falling, it can have a negative impact on the company's sales.

However, a weak economy doesn't mean investors should avoid Home Depot. There are a few reasons investors should expect to make at least a decent return by buying shares at current price levels.

Home Depot's performance during the 2008 recession

The U.S. economy has dealt with numerous recessions over the last century, but there haven't been many as severe as the mortgage crisis in 2008. Home Depot's revenue fell 8% that year, and revenue continued to fall through 2009 before it started growing again. 

The recession in 2008 placed the ultimate stress test on Home Depot's business. While it survived those challenges, Home Depot could see a similar pressure on its top-line performance if consumer demand suddenly falls.

HD Revenue (TTM) Chart

HD Revenue (TTM) data by YCharts

Other data released by the NAHB shows that the weakening economy is starting to impact consumers' appetite to spend on their homes. The NAHB/Westlake Royal Remodeling Market Index (RMI) finished the second quarter at 77, down 10 points year over year. A reading above 50 is good, so overall there is still a healthy amount of demand for home remodeling projects.

However, Home Depot has already started to feel a negative impact from economic headwinds. Management reported that higher prices for goods caused by cost inflation pressured average order values last quarter. That contributed to a comparable sales growth number of 3% year over year, compared to 8.1% in the fiscal fourth quarter of 2021. 

The expectation for slowing revenue growth has sent Home Depot's stock price down 28% year-to-date, but this could present an excellent buying opportunity. Just because revenue might suffer during a recession doesn't mean the stock can't go higher.

Home Depot's revenue fell 7.8% between fiscal 2006 and fiscal 2012, but the stock still climbed 64% over that time period. There are a few reasons the stock should rebound from this episode as before.

HD Chart

HD data by YCharts

Home Depot excels at allocating capital in ways that grow the value of the business. Over the last 10 years, profit margin improved from 6% to 11%. With the recent investments management has made in new fulfillment centers and improving the supply chain, investors should expect Home Depot to continue growing profits over the next decade.

HD Profit Margin Chart

HD Profit Margin data by YCharts

One of Home Depot's top priorities is to expand its fulfillment network to reach 90% of the U.S. population with same or next-day delivery, including large, heavy items. 

Home Depot is a safe investment

While Home Depot is not recession-proof, since sales can decline when the housing market weakens, it is still a safe stock to hold for the long term. Management doesn't stop looking for ways to strengthen the business, so investors should expect Home Depot to exit a downturn in the economy stronger than before.

It's also a bonus that Home Depot pays out over 40% of its profits to shareholders via dividends. So with a lower valuation and a corporate culture that never takes its foot off the gas, the stock is a great investment.