Every company lays off their own way. When I've had to get involved in layoffs the decision comes from upper management. It's either "Shut down this department or project" or "Cut x% from your payroll." If a whole department or project gets shut down then some of the people working in that group may have the opportunity to move to another group. If the layoff is about cutting payroll I've always seen it as a spreadsheet ordered by salary with some names hilited because they are considered too valuable or irreplaceable, or get to keep their jobs for some other reason. Some people get laid off regardless of salary because it's a convenient way to fire them.
Any money spent obtaining a visa like an H1B is already spent, it's not part of the ongoing payroll expenses, so I doubt it comes into the equation. Some companies pay people on visas less because the visa is tied to the job, reducing the employee's options and bargaining power. Finding yourself lower down on the salary spreadsheet may work to your advantage.