Is my problem delta time or just bad code

I have extensively researched this on here and elsewhere and while I have read a lot I am just not seeing where this code is not working. The problem only exists when the game is not the active tab in the browser. I read something in another post about some browsers throttling inactive tabs but I would think even it was only processing 1 frame a minute that deltaTime would be correct.
public void earn() { if (count > 0) { time += Time.deltaTime; //if time goes over the time to act while (time >= timer) { //remove one cycle worth of time time -= timer; //give cash float cashToAdd = valueFormulaRemovedForClarity; += cashToAdd; gm.totalEarnings += cashToAdd; } } }

A while loop can easily stop the execution if used incorrectly. Everything outside the while loop is not updating while the while loop runs. So Time.deltaTime is only called once before the while loop so depending on whatever timer is it is becoming very brittle. You may want to restructure your code to use an if statement and a for loop instead.