It definitely depends 100% how the filters were stored. In your situation, I would not use anything over 5 years old, period. Even if it's under 5 years old, inspect everything very closely including the gasket. It could have been cooking in a garage for years which might weaken the gasket. Also shake it and listen for noises. If everything meets your approval, buy it and wrap it in a plastic bag and put it back in the box until you use it -- that's what I do with all my filters to keep moisture out.
I bought some new old stock (NOS) Mobil 1 EP filters from Rock Auto for $3 apiece (clearance). Date code said they were 9 years old so I cut one open and it looked perfect, the bypass valve and base gasket were still pliable and fresh. Using with confidence, no problems.