I've used spray foam multiple times for this task, and it has worked well for me.
It certainly is quick and easy.
Just note that spray foam expands, so you may need to spray less than you think.
Some foams give off an odor as you spray it out, so I ventilate appropriately when using them. I don't know about toxicity of the fumes.
Many spray foams are ...
"Update: this is a BROR cabinet so it’s a steel material. [...] I was
going to use the bottom set of holes to attach to the wall. Is it ok
to do that? I only plan on keeping lighter weight stuff in it (paper
towels, etc) so additional 15-20 lbs at most."
To add to other answers, another reason why it is absolutely wrong to only use the bottom ...
If you use the middle set of holes instead of the top one, traction load on the screw (red) will be about double with the same weight in the cupboard( blue). That's due to leverage.
How about just driving the screw into the stud at an angle to dodge the damage done by the previous accident?
Assuming that to the right in the photo is “the other cabinet” you mentioned, you probably don’t want this approach and should use one of the other answers, since you’d probably have to redo that. But this will definitely work, and if I assume incorrectly and you haven’t put up the other cabinet yet (or for other readers in a similar situation but who haven’...
There's a further option not mentioned above, and one that may suit someone less handy:
Use a solid wall anchor or threaded insert. Using an anchor or insert would allow you to continue to use the existing hole in the cabinet. There's plenty of variations of wood anchors but options include Screw-it-Again and EZ Lok threaded inserts. The Screw-it-Again ...
Continuing from Solar Mike's excellent answer:
Use a longer screw. However, one must be sure that there is no electrical or plumbing behind that point that could be penetrated by the longer screw.
Put the screw somewhere else vertically. It may mean drilling a hole in the back of the cabinet to run the screw through instead of using the predefined hole. ...
I would be considering two options:
using larger screws into the stud.
gluing a dowel into the hole in the stud, even drilling out the hole to 6mm or 8mm and then, once the glue is dried drilling a pilot hole for the new screws.
For me Option 2 is my preferred choice.
I am certain it originally held some 1950s record player (less likely, a reel-to-reel player), with the cut-out to lower the clearance height. Below are pictures of the more typical cabinet with the flip-top lid to access the equipment, but also an example of a drawer mounted unit with a similar oddball cut-out. Other styles also included a slide-out drawer ...