If you are next to your friends then you can use Local Wireless to trade, battle, etc, which means they don't need the online membership. However, if they are not next to you then they need an online membership so they can battle, trade, etc with you or anyone across the world.
"A Nintendo Switch Online subscription is not mandatory for Pokemon Sword & Shield. Still, it is beneficial to have one - you won't be able to trade Pokemon, find other players camps, or battle online without it."
Source