In an expensive market, buying cheap stocks often means investing in companies that are going through some serious issues. But the best time to buy a stock is often when no one else wants anything to do with it. It's worth taking a look if everyone seems to be running away.

Toy maker Mattel (NASDAQ:MAT), apparel retailer Gap Inc. (NYSE:GPS), and shoe seller Foot Locker (NYSE:FL) have no shortage of problems between them. But low expectations combined with rock-bottom valuations make all three stocks potential value opportunities.

Keyboard keys spelling "BUY NOW."

Image source: Getty Images.

Mattel

Mattel has been trying hard to turn itself around for the past few years, after falling victim to a stifling corporate culture whose endless meetings and slow decision-making hindered its ability keep up with rivals. In late 2014, the company went so far as to create rules aimed at minimizing excessive meetings, limiting the number of people per meeting and capping the number of meetings before a decision would be made.

Those changes haven't helped the company's results. Revenue and profits tumbled in both 2015 and 2016, and the stock has been hammered. Since their price peaked in early 2014, shares of Mattel are down a whopping 65%. This was a world-class toy company just a few years ago, but it's now overshadowed by the likes of Hasbro and Lego.

Mattel has a new CEO, former Google executive Margo Georgiadis, who will try to return the company to its former glory. The company owns plenty of well-known brands, including Barbie, Hot Wheels, and Fisher-Price, but execution has been its main problem. Mattel stock doesn't look all that cheap relative to earnings, which have dropped thanks to that poor execution, but it still trades for the lowest multiple of sales since 2009.

MAT PS Ratio (Annual) Chart

MAT PS Ratio (Annual) data by YCharts

Turning around Mattel won't be easy. But somewhere, buried within it, is a world-class toy company waiting to reemerge. The company today is valued at just about its annual revenue, compared to a price-to-sales ratio of about 2.3 for Hasbro. It won't take blockbuster results to start closing that gap, and investors willing to bet that the worst is over for this beaten-up toy company should consider its shares.

Gap Inc.

Staying away from brick-and-mortar retail seems like a reasonable idea these days, given the  upheaval currently plaguing the industry. But retail isn't dying, it's simply changing. Investing in strong retailers with long track records undergoing temporary issues and trading at low valuations can be a lucrative strategy for those willing to wait out the storm.

Gap, which operates stores under its namesake brand as well as Banana Republic, Old Navy, and Athleta, has suffered along with most mall-based apparel retailers. Its sales have slumped for the past two years, and margins are now well below peak levels. But it has shown signs of life recently, with three consecutive quarters of positive comparable sales growth, and four consecutive quarters of gross margin expansion. The star of the show has been Old Navy, which caters to value-conscious consumers, but that's been enough to drive growth for the company.

Gap expects to produce adjusted earnings per share between $2.02 and $2.10 this year, putting the P/E ratio at roughly 11. The company doesn't really have much of a moat, with intense competition from a wide variety of apparel retailers. But it's growing comparable sales at a time when many rivals are suffering major declines. And a 3.9% dividend yield certainly doesn't hurt.

Foot Locker

After Foot Locker's most recent earnings report, investing in it would take a cast-iron stomach. Comparable sales dropped 6%, gross margin tumbled 3.4 percentage points year over year, and adjusted earnings per share dropped 34% -- all of which sent the stock plunging. The company blamed weak demand for recent top styles for its poor results, as well as limited availability of innovative new products. Foot Locker expects these issues will persist through the rest of 2017.

Foot Locker stock now trades for around $35 per share, about 8.8 times analysts' average  earnings estimate for the current fiscal year. Back out the more than $900 million of net cash on the balance sheet, and the P/E ratio falls to just 7. The fundamental question: Is Foot Locker doomed by dying malls and surging online retail, or can it work through its current issues?

There's no doubt that Foot Locker faces a long-term threat from e-commerce, and its margins may be permanently lower in the future as a result. A single-digit P/E ratio doesn't mean much if earnings continue to tumble, and I think you have to assume that its bottom line is going to keep hurting. But at some point, a stock becomes cheap enough that almost anything short of catastrophe can lead to good results for investors. Foot Locker's share price may not be quite there yet, but it's getting close.

Timothy Green has no position in any of the stocks mentioned. The Motley Fool owns shares of and recommends Hasbro. The Motley Fool has a disclosure policy.