there are many indirect effects. Imagine a factory employing 80 low-wage "takers" (line workers etc) and 20 high-wage "makers" (managers etc). The owners of the factory make $1 million in profit every month as a taxable dividend. Well if you get rid of the line workers: no more factory, no more managers, no more dividend. This is why honest analyses go beyond simple tax balance accounting.
The other big impact is on price level. When you have an inverted population pyramid, fewer workers need to support more retirees and this shows up as inflation concentrated in labor-intensive industries like healthcare. So even if a program like Medicare really had more tax receipts per beneficiary after reducing immigration, it would also be spending much more per beneficiary under a labor shortage.