Most people would say yes indeed, but to be more broadly correct: Some notes will be harder for some people to accept than others. Those that are actually part of the chord will sound best, but sometimes a non-chord tone will add what could be called an interesting/appropriate flavor (or "bad sound" to some). The latter would be a judgment call, which might vary depending on who's judging, what the mood of the song is, etc. Chord tones are the 1st, 3rd, and 5th notes of the scale of the chord. Example: the 1st, 3rd, and 5th notes of a C scale are C, E, and G. Those three notes combine to make a C chord. With G it would be G, B, and D combining for a G chord. Et cetera.
The note G is the 4th tone of a D scale, so it's a dubious fit. But Scruggs makes it sound likable with the D chord in Jed Clampett. Generally, an E chord with the open 5th string G sounding, is considered nasty. But Tony Trischka uses it to good effect on his tune Bloosinee (Blues in E). So "belong with", or "can you play" can end up as judgment calls, not necessarily hard rules.
Main thing is, keep picking -- and listening!