San Francisco has become the first city to mandate full pay for parents who take leave on the birth or adoption of a child.

According to the legislation, lost pay is the primary reason workers fail to take advantage of existing California law that enables them to receive 55 percent of their wages (and up to 70 percent beginning in 2018) while on leave to care for a new child or ill family member.

The San Francisco legislation, which Mayor Ed Lee has not yet signed into law, seeks to remedy this by requiring companies with 20 or more employees to make up the difference between what employees receive through a special state fund and their full pay.

Many have applauded the new law and a similar one set to take effect in New York in 2021. But before we hail these changes as a win for families, we should consider the economic implications.

First, leave is not free. Someone foots the bill. Under existing California law, workers, regardless of age or whether they have or will have children, must pay into the state program that provides the 55 percent of wages.

Second, this legislation places new costs on employers. Consider a firm with 25 employees. According to the U.S. Bureau of Labor Statistics, the average hourly wage for the San Francisco-San Mateo-Redwood City region is $33.34. At 40 hours a week, 52 weeks a year, that’s $69,347 per employee.

When a worker takes leave to care for a new child or a family member, owners and managers not only must pay 45 percent of that worker’s wages, but also must make up for the lost labor by hiring a temporary worker or paying overtime to other employees. Both options mean paying more in gross wages and additional costs in Social Security and Medicare taxes. Even a small increase in costs would have a significant impact.

Even large, profitable firms may operate on razor-thin margins. Walmart’s profit margin is only 3 percent. Its costs are so large that in a 31-day month, the first 30 days’ sales go to expenses. Only on day 31 does the company turn a profit, assuming nothing unexpected happens—like a new family-leave law.

Some people still find the city’s policy acceptable. As long as families aren’t paying the price, they say, the costs are worth it. But in reality, families do pay.

Firms will be less likely to hire people apt to take leave. Women, who are more likely than men to take family leave (both at the birth of a child and as the child gets older), particularly will suffer.

It’s not difficult to see how mandates like the paid leave affect the employment prospects of certain groups—married women of reproductive age, young women generally, and even married men. If a firm knows that an employee in a particular category is likely to cost more, it will be less inclined to hire him or her.

Put yourself in a business owner’s shoes. You can choose between two job candidates. One is a 27-year-old female with an engagement ring. The other is a 45-year-old man. They are equally qualified—or maybe the woman is even slightly better qualified. But you know there is a good chance that within the next few years she’ll have baby. That baby is going to cost you. So you choose the older man. In other words, you discriminate. It’s not because you’re a misogynist or hate families. It’s because you’re trying to run a business.

Helping families is admirable, but we should be cautious before suggesting that the government mandate how employers handle their businesses. You’re liable to make them and the families suffer.