The best time to buy a stock is often when it's been left for dead. In some cases, pessimism can drive down a stock so much that anything short of disaster can lead to solid long-term returns for investors.

One beaten-down stock that looks like it could fall into this category is Sonos (SONO -0.93%). Demand for the company's speakers has slumped, but the long-term growth story is still intact. Wayfair (W 2.08%) is a different story, and while it can be tempting to jump in at a depressed price, there's not a lot to like about the online furniture seller.

Buy Sonos

Shares of connected home audio specialist Sonos have taken a beating over the past few months. The stock tumbled in May following a quarterly report that beat analysts' expectations but featured lackluster guidance. Sonos is suffering from weak demand for its pricey speakers and home theater equipment amid a tough economic environment.

Sonos now expects revenue to decline by 4% to 7% this year. In the fiscal second quarter, which ended April 1, a combination of weak consumer demand and excess channel inventory led to a 23.9% sales decline. The company is taking steps to bring costs down, including laying off 7% of its workforce, which will help prop up the bottom line to a degree.

While Sonos is struggling right now, there's a lot to like about the company. First and foremost, Sonos has built a brand that's synonymous with quality. Sonos' products are expensive, but you get what you pay for. And unlike smart speakers from big tech companies, Sonos' platform is agnostic when it comes to integrations. The company's products work with more than 130 content providers, a wide range of home automation systems, and multiple voice assistants.

Sonos' brand will help it tap into an enormous total addressable market. There were 14 million households with Sonos products at the end of 2022, and the company estimates that there are 172 million affluent households in total within its core markets. With just 8% penetration, Sonos has a long growth runway ahead of it.

While Sonos' products may not be in high demand during a recession, the company's balance sheet is strong enough to carry it through just about anything. Sonos has no debt and about $295 million in cash. Free cash flow was positive through the first six months of fiscal 2023 despite the steep revenue decline.

A recovery for Sonos stock will take time, but the company has all the necessary ingredients to be a long-term winner.

Avoid Wayfair

While shares of online furniture and home goods retailer Wayfair surged in June, the stock remains down more than 80% from its all-time high. Like Sonos, Wayfair is fighting against slumping demand for its products. Unlike Sonos, the long-term picture for Wayfair doesn't look particularly bright.

Outside of a period during the pandemic when home-bound consumers were flush with stimulus cash, Wayfair has struggled to turn a profit. With revenue tumbling and customers abandoning the retailer, the bottom line is falling off a cliff. Revenue slumped 7.3% year over year in the first quarter to $2.8 billion, and the company posted a net loss of $355 million. Free cash flow was a loss of $234 million.

Wayfair's financial performance, its lack of any meaningful competitive advantage, and its rapid-fire cash burn are good reasons to avoid the stock. Management is another. The company and CEO Niraj Shah have made producing positive adjusted EBITDA, or earnings before interest, taxes, depreciation, and amortization, a key goal of the turnaround effort. That's a big red flag for investors.

EBITDA has severe shortcomings as a profitability metric. It ignores real costs, casting aside capital expenditures and the resulting depreciation entirely. While Wayfair is burning through more than $200 million in cash each quarter, adjusted EBITDA is on the cusp of turning positive. Unfortunately, you can't spend adjusted EBITDA.

A prolonged period of weak consumer demand is not going to treat Wayfair kindly, and management is driving toward the wrong goalposts. Investors would be wise to stay away from the stock.