Im a bit confused. Which of these is right?

мы были у бабушки в гости.

or

мы были у бабушки в гостях.

If they are both right...when do you use which?

Thanks!