The 21-year-old made seven appearances for the Hammers and netted his only goal for them in a Europa League qualification round match against Andorran side FC Lustrains last season.
Lee had two loan spells in League One last term, with Blackpool and then Colchester United.
He scored twice for the U's but was unable to save them from relegation.
The length of Lee's contract with the promoted Tykes has not been revealed.
Find all the latest football transfers on our dedicated page.

Firefighters were called to the Italian's detached Cheshire house when the explosive set alight his bathroom in the early hours of Saturday morning.
Police said it was an accident and have decided not to take any action.
The incident happened less than 48 hours before leaders City travel to neighbours Manchester United in a table-topping Premier League clash.
Officers confirmed Balotelli, 21, was inside the property in Mottram St Andrew but it is believed he did not set off the firework.
PC Shelley Williams, from Cheshire Police, told the Manchester Evening News newspaper: "At just before 1am on the morning of Saturday 22 October, Cheshire Police were called to a report of a house fire at a residential home on Oak Road, Mottram St Andrew near Macclesfield.
"Police provided assistance to Cheshire Fire and Rescue Service in ensuring residents were accounted for and there was no danger to surrounding properties.
"At this time the cause of the fire is being examined by fire investigators and police. However, it is not thought to be suspicious."
Four firefighters arrived wearing breathing apparatus and used two hose reel water jets to douse the flames and a large fan was also used to clear smoke from the house.
Balotelli has been involved in a number of controversial incidents since joining City in a reported £24m move from Inter Milan in August 2010.
He was sent off against Premier League rivals West Brom in November before his manager Roberto Mancini labelled him "stupid" for seeing red again in a Europa League game against Dynamo Kiev.
Only last week he was embroiled in a spat with Aston Villa fans after netting in City 's 4-1 win against their side.
And City officials launched an investigation in March after the Italy international threw a dart towards a youth team player at the club's Carrington training ground.
Barnsley have signed striker Elliot Lee from Premier League club West Ham United for an undisclosed fee.
[NEXT_CONCEPT]
Manchester City striker Mario Balotelli escaped unhurt when a firework was launched inside his home.