Sales of desktop, notebook, and workstation computers tumbled in the eight years leading up to the pandemic. Unit shipments dropped from nearly 350 million in 2012 to just 268 million in 2019 as demand for smartphones and tablets exploded.

As working and schooling from home became a necessity in early 2020, demand for PCs bounced back. The industry shipped 304 million units in 2020 and 349 million in 2021. Even as pandemic restrictions were lifted, PCs kept flying off the shelves.

The bonanza now appears to be over. PC shipments jumped nearly 15% in 2021, but by the fourth quarter, growth had slowed to just 1%, according to data from IDC, the global market intelligence firm. IDC expects shipments to plunge 8.2% in 2022, largely driven by the consumer and education markets. Demand for commercial PCs remains strong, although that might not remain the case as economic uncertainty and inflation weigh on businesses.

HP's profits could be in trouble

HP (HPQ -0.93%) is the second-largest seller of PCs, shipping around 20% of units globally in the fourth quarter of 2021. PCs were not particularly profitable before the pandemic; the company managed an adjusted operating margin of just 3.7% for its PC segment in 2018.

Not only did the company's PC sales soar during the pandemic, but so did profits. HP reported an adjusted operating margin of 7.2% for the PC segment in 2021. Selling notebooks and desktops became much more lucrative: The PC segment produced nearly as much operating profit as the high-margin printing business last year.

The big question is whether this can last as demand for PCs sinks. Revenue from commercial PCs accounted for roughly 65% of the company's PC revenue in the second quarter of this year, so if demand remains strong from businesses, the bottom line should hold up reasonably well. But if businesses start holding off on upgrades as cost containment becomes the name of the game in a weak economy, the commercial business could follow in the footsteps of the consumer business.

HP is already seeing unit sales tumble, but higher prices have been enough to offset those declines. Overall PC unit sales slumped 17% in the second quarter, with notebooks being hit particularly hard. But even as notebook units dropped by 23%, notebook revenue rose by 3% thanks to strong demand on the commercial side.

On the one hand, remote work is here to stay, so demand for PCs from businesses could be permanently higher than before the pandemic. IDC expects PC unit sales to return to growth after this year, albeit at a slow pace. Even with a big decline in 2022, PC sales are expected to remain well above pre-pandemic levels.

On the other hand, if the U.S. economy enters a recession, businesses will be looking to scrap any unnecessary spending. Employees might get new laptops less frequently, or only if there's a good reason for an upgrade. Big companies have been announcing hiring freezes, an indication that businesses are starting to take costs seriously. Notably, PC chipmaker Intel has reportedly frozen hiring in its PC chip division. None of this bodes well for commercial PC demand.

Shares of HP are trading right around their multiyear high, unscathed by the recent tech stock sell-off. That could change abruptly if the commercial PC market starts showing any weakness this year.