There are two parts to answer this question. "How does my body know when to pee? Do diuretics affect that, or my hydration?"
Does wanting to pee imply dehydration?
In summary: Not necessarily. Your body might have plenty of water, but the bladder is full. Alternatively your body might be dehydrated, but the caffeine and normal body functions have filled the bladder and you'll need to pee.
Caffeine as a diuretic.
Caffeine belongs to the Xanthines, and inhibits reabsorption of Na+ by cells, and increases flow rate of filtered fluid through the kidneys. This reduces water content in your body. In other words diuretics do dehydrate you, specifically caffeine will. Coffee and tea (very low doses of caffeine) are mild diuretics.
Bumetanide, Furosemide, and Torsemide are examples of stronger diuretics, and hydration should be monitored closely.
On the other hand, the colour of your urine may indicate your hydration.
The below image is a crop of this Cleveland Clinic infographic.

How does my body know when to pee?
The bladder is hollow and slightly elastic, so as it fills with urine it expands. A healthy bladder can hold up to 2 cups of urine comfortably for several hours. When the bladder approaches its maximum capacity, signals are sent to the brain, letting the body know that it is time to urinate.
But it's critically the kidneys that are controlling the production of urine.
Caffeine increases the production of urine from the kidneys, and fills the bladder quicker. However, the increase in production of urine from a cup of coffee is more than offset by the water in the coffee.