I think it is important for everyone to note that no one is necessary to a company's future. If you work for a company where that is true of you, or any other employee, it is a bad position to be in. You work for an extremely shaky employer.
At the end of the day, layoffs do not happen based on merit. They happen based on cost, or revenue, or a wide variety of other factors outside of your control. I've been in meetings where 1 group that was demonstrably better by every metric we picked was still let go over another group. The reason was the lease terms on the office space they were in.
Anyone that tells you that you can save your job in the face of layoffs due to changing your working habits is manipulating you.