Yup! That's the point that gets talked past a lot in the welfare-immigration debate, as each side emphasizes only the facets that buttress their argument.
Welfare and immigration must be balanced, to some degree, in that total_production of a country needs to pay for total_welfare.
What gets lost is why welfare.
I'd say most Democrat would say "Because it's a moral imperative" and most Republicans would say "It's allowing people to be lazy."
Imho, both of those may be true to various degrees, but its utility is the prevent the negative consequences of extreme poverty, which also impacts those in extreme poverty's ability to lift themselves out of it and the next generation born into that situation, both of which ultimately impact the economy.
So a case of saving/making (future) money by spending (current) money.
That said, obviously even the US can't afford to provide welfare for the entire world's population, so there needs to be some cap to the immigration flow (probably much higher than the current legal limits).
Although it does fund 1/3 of the UN [0] and is the 2nd largest independent aid funder [1] (via USAID, behind China on an absolute basis, and behind many others on a per-GNI basis).
[0] https://www.cfr.org/article/funding-united-nations-what-impa... [1] https://en.m.wikipedia.org/wiki/List_of_development_aid_sove...